Sockets provide communications between DBserver, drivers, clients and the outside world. As with all resources on computers the possible sockets available for use are limited and if they get used up it can cause problems with ClearSCADA.
By default, on Windows, the ephemeral ports are in the range 1024 to 5000. Ephemeral ports are allocated to processes need to be able to communicate but don't require a specific port number. ClearSCADA uses ephemeral ports for the following communications:
ViewX to server connections
Server to ViewX advise connections
WebX to server connections
Telnet listen ports for diagnostics
If you run out of sockets the above connections may have problems establishing fully (or at all) and so you will have problems on the system, such as drivers not starting or ViewX not connecting. Remote diagnostic facilities (Remote Desktop, VNC, remote file access, etc) will also likely be affected.
Finding Out Socket Usage
The simplest way to find out the sockets currently in use is to use the inbuilt Windows netstat command.
'netstat -ano' or 'netstat -bn'
The above command will list all active sockets. You will be able to see sockets that are waiting for a connection, have established, are waiting to expire, etc. If you see a large number of sockets and the range 1024-5000 all showing in use this indicates a potential socket issue. Note that netstat shows all sockets, not just those on the ephemeral ports.
Sadly netstat doesn't show which process is using which socket, all it tells you is how many sockets are in use. To find out which socket is being used by which process (and so which process could be having issues) you can use the Sysinternals] tool TCPView. This is a graphical tool that will show real-time information about sockets and their owning process.
tcpview.png The above screenshot shows an example TCPView session (PL183 is the local host name). It has examples of dbserver.exe listening on port 5481 and 8080, an outgoing client advise connection to port 5500 and an incoming client connection from port 4971.
The above screenshot also shows the example dbserver-driver connection, for example between dbserver and DriverModbusSlave on ports 4979 and 4974 respectively.
TCPView also comes with tcpvcon.exe, a command line based version which can be used in place of netstat in automated batch files.
Causes of Increased Sockets
The following items list possible causes as to why you are using more sockets than "normal"
Each ViewX client will use a few sockets.
Other clients will use sockets, although less of them.
TCP/IP outstations will all make individual socket connections.
Resource leak, such as a bug in code not closing sockets when not in use anymore or network card driver issues.
Increasing the Available Ports
The default range of 1024-5000 is fine for normal usage however with ClearSCADA it sometimes isn't enough. There are two options, both of which can be implemented as deemed necessary.
Increasing the Range
You can increase the maximum port value from the default 5000. This is configured in
When a socket is closed it hangs around in memory in case the process wants to use it again (see TIMED_WAIT in above screenshot). This is for efficiency reasons but can mean more sockets are out of selection if a lot of sockets close and open regularly. The timeout it waits can be dropped from the default of 240 to something less as required.