quickfix.RuntimeError: java.net.BindException: Address already in use: bind

quickfix.RuntimeError: java.net.BindException: Address already in use: bind

book

Article ID: KB0081204

calendar_today

Updated On:

Products Versions
TIBCO Streaming 7.x, 10.x

Description

In some cases, a StreamBase application which uses the FIX adapter (as acceptor) cannot start the FIX session due to the following error:
2018-07-31 08:22:11.311-0400 [FIXEngineManager] ERROR FIXInput_2 - FIXInput_2: Exception caught trying to start FIX connection.
quickfix.RuntimeError: java.net.BindException: Address already in use: bind
	at quickfix.mina.acceptor.AbstractSocketAcceptor.startAcceptingConnections(AbstractSocketAcceptor.java:147) ~[quickfixj-all.jar:StreamBase-7.7.4.2826]
	at quickfix.ThreadedSocketAcceptor.start(ThreadedSocketAcceptor.java:47) ~[quickfixj-all.jar:StreamBase-7.7.4.2826]
	at com.streambase.sb.adapter.fix.engine.quickfixj.SessionHandler.startFIXConnections(SessionHandler.java:537) ~[sb-fix-core.jar:7.7.4ilik2_261059-personal/fpoulin/ilink2-1805231407]
	at com.streambase.sb.adapter.fix.FIXEngineManager.run(FIXEngineManager.java:346) [sb-fix-core.jar:7.7.4ilik2_261059-personal/fpoulin/ilink2-1805231407]
	at java.lang.Thread.run(Thread.java:748) [na:1.8.0_171]
Caused by: java.net.BindException: Address already in use: bind
	at sun.nio.ch.Net.bind0(Native Method) ~[na:1.8.0_171]
	at sun.nio.ch.Net.bind(Net.java:433) ~[na:1.8.0_171]
	at sun.nio.ch.Net.bind(Net.java:425) ~[na:1.8.0_171]
	at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223) ~[na:1.8.0_171]
	at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74) ~[na:1.8.0_171]
	at org.apache.mina.transport.socket.nio.SocketAcceptor.registerNew(SocketAcceptor.java:363) ~[sbserver.jar:7.7.4ilik2_261059-personal/fpoulin/ilink2-1805231407]
	at org.apache.mina.transport.socket.nio.SocketAcceptor.access$800(SocketAcceptor.java:55) ~[sbserver.jar:7.7.4ilik2_261059-personal/fpoulin/ilink2-1805231407]
	at org.apache.mina.transport.socket.nio.SocketAcceptor$Worker.run(SocketAcceptor.java:222) ~[sbserver.jar:7.7.4ilik2_261059-personal/fpoulin/ilink2-1805231407]
	at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51) ~[sbserver.jar:7.7.4ilik2_261059-personal/fpoulin/ilink2-1805231407]
This error indicates that the SocketAcceptPort (defined in the FIX configuration file) is already taken up by another process.

Issue/Introduction

The message "quickfix.RuntimeError: java.net.BindException: Address already in use: bind" when starting a StreamBase application that uses the FIX adapter.

Resolution

To resolve this, first check to see if you have defined the same SocketAcceptPort for multiple un-linked FIX adapters in your application (i.e. input adapters which don't have the "Share a FIX connection with an ouptut adapter" option checked).  If you have un-linked adapters trying to use the same port, you must either link them or use different ports in the FIX configuration files defined for these adapters.

If you find that your application appears to be configured correctly, check to see if another process is using the SocketAcceptPort using netstat.  For example..
> netstat -ano | find "4321"
  TCP    0.0.0.0:4321           0.0.0.0:0              LISTENING       14908
  TCP    [::]:4321              [::]:0                 LISTENING       14908
In the above example, a process (PID 14908) is using the SocketAcceptPort defined in the FIX configuration file (4321).  You can then determine the process name using the 'tasklist' command on Windows or the 'ps' command on Linux/MacOSX.