Socket -> Connection refused issue - sockets

I'm having an issue with Sockets and i can't resolve the problem.
I have 2 distincts machines on the same network. I try to send an object from the first machine to the second.
The second machine is the server, a thread that open a ServerSocket on the port 1456 is running on it. I call the accept() method and it seems to work fine.
When I try to connect to the server from the first machine I receive a ConnectException, Connection refused.
I did a lot of research and found that the port i'm trying to connect to is probably close (firewall issue). I found that the antivirus "avast" blocks the port, so I disable the antivirus and it worked fine ! For 5min...
I uninstalled the antivirus and then it became impossible again to connect to the server. I disabled the windows firewall on both machines. I restarted the machines after each actions.
Does someone have an idea about that?
thanks.

Related

io.netty.channel.connecttimeoutexception connection timed out

after a change in the IP, our server has stopped working. Only the host can connect to the server. we already tried Whitelisting Java and the port, restarted the router, reinstalling java, and even made another complete server. It just stopped working. does anyone have a solution to this?
Have you port forwarded your router correctly?
If not then only connections from your LAN network can connect to the server.

PostgreSQL Connection to the server has been lost

I installed postgreSQL server on a raspberry pi 4 with raspbian buster. When I try to connect from local network i have no problems about idle time. When i try to connect from my static public ip I can send command but if I didn't send anything for more than 3 minutes, it appears this message "Connection to the server has been lost".
I tried to install ufw and disable it, I used DMZ, I tried to change keepalive_idle, but i have always the same problem. Please help me.
sometimes the error is
"ERROR: SSL SYSCALL error: Operation timed out"
(Note: always if I am connected from public IP)
If you don't have the same issue from within your local network I assume the connection is being terminated by a network device sitting between the client and the server (a router most likely).
There are routers with small TCP timeout settings (such as 300 seconds) which is close to what you're experiencing.
Try to check (and increase if needed) the TCP timeout settings on your router (and any other devices you might have in between).
Edit:
I tried to find some info on that device (seems to be Sercomm VD625) and it does not seem you can easily change TCP timeout settings (maybe via telnet/ssh if it supports it).
However, a simpler solution might be to avoid keeping an open connection to PostgreSQL if you will have large idle intervals; just connect when you need to and close the connection afterwards.

Debugging with XDebug and Netbeans from Windows to Ubuntu remote server

I'm trying to debug a Drupal 7 app with Xdebug. My app resides remotely in a server with Ubuntu running Apache.
In Netabeans, I started a proyect with "Application From Remote Server", connected with SFTP.
In the remote server I have installed Xdebug as zend_extension, also i configured xdebug.remote_connect_back=1, xdebug.remote_autostart=1, etc... I've tried everything with no luck.
The log from Xdebug has entries like this one:
Log opened at 2014-12-24 13:01:31
I: Checking remote connect back address.
I: Remote address found, connecting to 181.175.73.24:9000
E: Time-out connecting to client. :-(
Log closed at 2014-12-24 13:01:32
Based on the log it seems that my computer is not visible from outside on port 9000. But port 9000 in my laptop is opened, listening, with Netbeans, that's what happens when a debug sessions starts.
I think it's a problem with my ISP. My IP is not only for me, so I can't manage it's ports or other configuration. I think my PC is not visible from outside.
So, the question is, how can I avoid this limitation? What could I debug my APP from my computer on a remote server?
Every answer is welcome. Using a program, using a service, both... I tried using pagekite but honestly I couldn't find a configuration that works for me.
Thanks everyone.
PD: I don't want Xdebug alternatives that don't do step by step debugging.
PD2: My Xdebug config is attached.
remote_connect_back won't do it for you, it just tries to connect to the public ip, it's nothing magic.
Can you ssh on the remote server ? You might want to try port forwarding over a reverse ssh tunnel.
Full details from the creator of xdebug:
http://derickrethans.nl/debugging-with-xdebug-and-firewalls.html

My netty TCP/IP server stops listenning few hours after starting

I have written TCP/IP server using Netty4.0 running on a Linux machine listening to small GPS tracking devices. I have been facing weird problem, which is server stops listening to them in a sudden several hours after I starts it. There is any error log I can see and still server is running. It looks like only channel is not working. When I run a client to do health check, the client socket is still alive and keep sending packet to the server but server does not get it.
If you have any idea how to solve it, please tell me about it. It would be appreciated.
It is impossible to tell without more informations. I would check different things like if there was an OOM exception or with telnet if the server really refuse connections etc. Also jstack may show you if there is some deadlock etc.

What's Difference Between Ubuntu Server (32bit) and Desktop (32bit) In Socket Programming

I am working on a server/client based project. I almost finished my server side code.
I develop the server app in EclipseCDT on Ubuntu Desktop, and everything just works fine.
But when deploy my app to a Ubuntu Server (I tried Server 10.04/10.10), the server app can start normally (waiting for connection), but the same client just cannot connect to the server.
I use Socket for receiving and sending data to/from the client.
Peter
P.S.: if I install sudo apt-get install ubuntu-desktop on my server machine, then everything works fine again.
===========================================================================
New Findings from the source code:
LabelStartBlocking:
int newScoketId = ::accept(socketId, 0, 0); // socketId == 3 ::accept is define in socket.h
// waiting for connection
LabelResume: // if new connection coming
// Do something with newSocketId
The behavior difference between Ubuntu Desktop and Server is:
On Ubuntu Desktop version, when the server starts, it is blocked at LabelStartBlocking with the socket routine ::accept; and then if a new connection arrives, the server will resume at LabelResume and create a new socket connection using the return value newSocketId;
However, on Ubuntu Server version, when the server starts, it is also blocked at LabelStartBlocking with the socket routine ::accept, but if a new connection arrives, the server won't resume at LabelResume, and the new socket connection CANNOT be created.
Can you guys help me out?
Peter
Thanks for your attention.
I finally figured it out.
If there are more than one IP addresses for the same hostname (/etc/hosts), the old code will fail.
Example /etc/hosts file:
127.0.0.1 localhost YourHostName
10.50.10.251 YourHostName
I traced the calling stack, and I found that, the IP address (10.50.10.251) passed to the program is translated into hostname, and then later the hostname is translated back to IP address (for binding), but a DIFFERENT one, that's why my server program cannot accept any client connection.
Hope it helps if any others have the similar issue.
Peter