An error log
An error
Normal
Such as online ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ali ga
CodePudding user response:
CodePudding user response:
Cessing failed; Nested exception is cn. Hutool. HTTP. HttpException: Connection refused] with root causeJava.net.ConnectException: Connection refused
The at java.net.PlainSocketImpl.socketConnect (Native Method) ~ [na: 1.8.0 comes with _20]
At java.net.AbstractPlainSocketImpl.doConnect AbstractPlainSocketImpl. Java: (345) ~ [na: 1.8.0 comes with _20]
At java.net.AbstractPlainSocketImpl.connectToAddress AbstractPlainSocketImpl. Java: (206) ~ [na: 1.8.0 comes with _20]
At java.net.AbstractPlainSocketImpl.connect AbstractPlainSocketImpl. Java: (188) ~ [na: 1.8.0 comes with _20]
At java.net.SocksSocketImpl.connect SocksSocketImpl. Java: (392) ~ [na: 1.8.0 comes with _20]
The at java.net.Socket.connect (Socket. Java: 589) ~ [na: 1.8.0 comes with _20]
At sun. Security. SSL. SSLSocketImpl. Connect (SSLSocketImpl. Java: 649) ~ [na: 1.8.0 comes with _20]
At sun. Security. SSL. BaseSSLSocketImpl. Connect (BaseSSLSocketImpl. Java: 173) ~ [na: 1.8.0 comes with _20]
At sun.net.NetworkClient.doConnect NetworkClient. Java: (180) ~ [na: 1.8.0 comes with _20]
The at sun.net.www.http.HttpClient.openServer (HttpClient. Java: 432) ~ [na: 1.8.0 comes with _20]
The at sun.net.www.http.HttpClient.openServer (HttpClient. Java: 527) ~ [na: 1.8.0 comes with _20]
The at sun.net.www.protocol.https.HttpsClient.
At sun.net.www.protocol.https.HttpsClient.New HttpsClient. Java: (371) ~ [na: 1.8.0 comes with _20]
At sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient AbstractDelegateHttpsURLConnection. Java: (191) ~ [na: 1.8.0 comes with _20]
The at sun.net.www.protocol.http.HttpURLConnection.plainConnect0 (HttpURLConnection. Java: 1103) ~ [na: 1.8.0 comes with _20]
The at sun.net.www.protocol.http.HttpURLConnection.plainConnect (HttpURLConnection. Java: 997) ~ [na: 1.8.0 comes with _20]
At sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect AbstractDelegateHttpsURLConnection. Java: (177) ~ [na: 1.8.0 comes with _20]
The at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0 (HttpURLConnection. Java: 1281) ~ [na: 1.8.0 comes with _20]
The at sun.net.www.protocol.http.HttpURLConnection.getOutputStream (HttpURLConnection. Java: 1256) ~ [na: 1.8.0 comes with _20]
At sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream HttpsURLConnectionImpl. Java: (250) ~ [na: 1.8.0 comes with _20]
The at cn. Hutool. HTTP. HttpConnection. GetOutputStream (HttpConnection. Java: 437) ~ [hutool - all - 4.5.9. Jar!/: na]
The at cn. Hutool. HTTP. HttpRequest. SendFormUrlEncoded (HttpRequest. Java: 1012) ~ [hutool - all - 4.5.9. Jar!/: na]
The at cn. Hutool. HTTP. HttpRequest. Send (HttpRequest. Java: 984) ~ [hutool - all - 4.5.9. Jar!/: na]
The at cn. Hutool. HTTP. HttpRequest. Execute (HttpRequest. Java: 875) ~ [hutool - all - 4.5.9. Jar!/: na]
The at cn. Hutool. HTTP. HttpRequest. Execute (HttpRequest. Java: 845) ~ [hutool - all - 4.5.9. Jar!/: na]
The at cn. Hutool. HTTP. HttpUtil. Post (HttpUtil. Java: 167) ~ [hutool - all - 4.5.9. Jar!/: na]
The at cn. Hutool. HTTP. HttpUtil. Post (HttpUtil. Java: 154) ~ [hutool - all - 4.5.9. Jar!/: na]
CodePudding user response:
Feel like on ping network problems?CodePudding user response:
Is a network problem PHP there are tuning up Taiwan Java but did not appear this kind of question feel very confusedCodePudding user response:
Network no problem, the local test no problem then look at the server deployment environment and the machine have what distinction, could it be that the JDK version of the server is low, so don't use too new method, can use the JDK's own HTTP requests to visitIs sending HTTP requests
CodePudding user response:
Public String httpSendPost (url String, the String param) {PrintWriter out=null;
BufferedReader in=null;
StringBuffer result=new StringBuffer ();
Try {
RealUrl URL=new URL (URL);
URLConnection conn=realUrl.openConnection();
Conn. SetRequestProperty (" accept ", "*/*");
Conn. SetRequestProperty (" the content-type ", "application/json");
Conn. SetDoOutput (true);
conn.setDoInput(true);
Out=new PrintWriter (conn. GetOutputStream ());
Out. Print (param);
Out. The flush ();
In=new BufferedReader (new InputStreamReader (conn. GetInputStream ()));
The String line;
While ((line=in readLine ())!=null) {
Result. Append (line);
}
} the catch (Exception e) {
System. Out.println (" to send a POST request exception!" + e);
e.printStackTrace();
} the finally {
Try {
If (out!=null) {
Out. The close ();
}
If (in!=null) {
In the close ();
}
{} the catch (IOException ex)
Ex. PrintStackTrace ();
}
}
Return the result. The toString ();
}
nullnullnullnullnullnullnullnullnullnullnullnullnull