Home > Back-end >  Why local test no problem on the server to the Connection refused abnormal!!!!!!!!!!
Why local test no problem on the server to the Connection refused abnormal!!!!!!!!!!

Time:03-24

Recently in the development of a small program, you need to call up interface, given the small program can call interface is only five, so call up from the background of machine interface, but very tricky problems appeared, call up the interface of the local test machine no problem, I just have Connection refused to deploy on Linux!!!!!! And sometimes inconsistent with bad is normal, sometimes at the wrong, leaders help to look at, hold up online etc.! ~ ~ ~ ~ ~!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

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 cause

Java.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. (HttpsClient. Java: 275) ~ [na: 1.8.0 comes with _20]
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 confused

CodePudding 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 visit


Is 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
  • Related