0

I'm trying to connect to my google vps server, but constantly getting error :

java.net.SocketTimeoutException: timeout
java.net.SocketException: Socket closed

I've created system service on my server, which listens on the port 8080. I've forwarded the default http traffic to port 8080 and made sure ports 80 & 8080 are open:

iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080

sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT

sudo iptables -A INPUT -p tcp --dport 8080 -j ACCEPT

I've also saved the iptable rules : sudo apt-get install iptables-persistent

I've checked if the service actually listens on the port by sudo netstat -tunlp:

tcp6 0 0 :::8080 :::* LISTEN 5789/java -> it does

This is my retrofitBuilder in app, which is trying to connect to server with standard http port :

return Retrofit.Builder()
        .baseUrl("http://34.118.22.134/")
        .addConverterFactory(MoshiConverterFactory.create())
        .build()
        .create()
}

When testing the service locally, it works as expected,also the service on the servers works fine.

When I do sudo ss -ltnp, I see that port 80 is not in "listening state", only port 8080 and several others are. I dont want to use uwf to enable it because that will disrupt the SSH connection.

The postman can't reach server as well and it's throwing 500-internal server error.

I do not manipulate sockets in code in any way.

  • try changing `.baseUrl("http://34.118.22.134/")` to `.baseUrl("http://34.118.22.134:8080/")` – fukanchik Nov 14 '22 at 15:14
  • Already tried that but did not help. – randomdude0 Nov 14 '22 at 15:16
  • Are you trying to connect from within the cluster or from outside internets? If latter try `curl http://34.118.22.134:8080/` -- it will hang. I suspect this is because of https://stackoverflow.com/questions/21065922/how-to-open-a-specific-port-such-as-9090-in-google-compute-engine – fukanchik Nov 14 '22 at 15:33

0 Answers0