You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by JJ <ge...@euronet.aero> on 2020/04/20 15:32:42 UTC

Continously java.net.SocketException: Connection reset

Simple MQTT connection produce continously errors, and after few seconds
client disconnection. 

activemq.xml is the default one.

Any help/hint?

java.net.SocketException: Connection reset
	at java.base/java.net.SocketInputStream.read(SocketInputStream.java:186)[:]
	at java.base/java.net.SocketInputStream.read(SocketInputStream.java:140)[:]
	at
org.apache.activemq.transport.tcp.TcpBufferedInputStream.fill(TcpBufferedInputStream.java:50)[activemq-client-5.15.12.jar:5.15.12]
	at
org.apache.activemq.transport.tcp.TcpTransport$2.fill(TcpTransport.java:634)[activemq-client-5.15.12.jar:5.15.12]
	at
org.apache.activemq.transport.tcp.TcpBufferedInputStream.read(TcpBufferedInputStream.java:59)[activemq-client-5.15.12.jar:5.15.12]
	at
org.apache.activemq.transport.tcp.TcpTransport$2.read(TcpTransport.java:619)[activemq-client-5.15.12.jar:5.15.12]
	at java.base/java.io.DataInputStream.readByte(DataInputStream.java:270)[:]
	at
org.apache.activemq.transport.mqtt.MQTTWireFormat.unmarshal(MQTTWireFormat.java:86)[activemq-mqtt-5.15.12.jar:5.15.12]
	at
org.apache.activemq.transport.tcp.TcpTransport.readCommand(TcpTransport.java:240)[activemq-client-5.15.12.jar:5.15.12]
	at
org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:232)[activemq-client-5.15.12.jar:5.15.12]
	at
org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:215)[activemq-client-5.15.12.jar:5.15.12]
	at java.base/java.lang.Thread.run(Thread.java:834)[:]
2020-04-20 16:06:07,128 | DEBUG | Unregistering MBean
org.apache.activemq:type=Broker,brokerName=AMBRACIA,connector=clientConnectors,connectorName=mqtt,connectionViewType=remoteAddress,connectionName=tcp_//xxx.xxx.xxx.xxx_47203
| org.apache.activemq.broker.jmx.ManagementContext | ActiveMQ Transport:
tcp:///xxx.xxx.xxx.xxx:47203@1883
2020-04-20 16:06:07,128 | DEBUG | Stopping connection:
tcp://xxx.xxx.xxx.xxx:47203 | org.apache.activemq.broker.TransportConnection
| ActiveMQ BrokerService[AMBRACIA] Task-2
2020-04-20 16:06:07,129 | DEBUG | Stopping transport
tcp:///xxx.xxx.xxx.xxx:47203@1883 |
org.apache.activemq.transport.tcp.TcpTransport | ActiveMQ
BrokerService[AMBRACIA] Task-2
2020-04-20 16:06:07,129 | DEBUG | Initialized TaskRunnerFactory[ActiveMQ
Task] using ExecutorService:
java.util.concurrent.ThreadPoolExecutor@113c1ae6[Running, pool size = 0,
active threads = 0, queued tasks = 0, completed tasks = 0] |
org.apache.activemq.thread.TaskRunnerFactory | ActiveMQ
BrokerService[AMBRACIA] Task-2
2020-04-20 16:06:07,130 | DEBUG | Closed socket
Socket[addr=/xxx.xxx.xxx.xxx,port=47203,localport=1883] |
org.apache.activemq.transport.tcp.TcpTransport | ActiveMQ Task-1
2020-04-20 16:06:07,131 | DEBUG | Forcing shutdown of ExecutorService:
java.util.concurrent.ThreadPoolExecutor@113c1ae6[Running, pool size = 1,
active threads = 0, queued tasks = 0, completed tasks = 1] |
org.apache.activemq.util.ThreadPoolUtils | ActiveMQ BrokerService[AMBRACIA]
Task-2
2020-04-20 16:06:07,131 | DEBUG | Stopped transport:
tcp://xxx.xxx.xxx.xxx:47203 | org.apache.activemq.broker.TransportConnection
| ActiveMQ BrokerService[AMBRACIA] Task-2
2020-04-20 16:06:07,132 | DEBUG | Connection Stopped:
tcp://xxx.xxx.xxx.xxx:47203 | org.apache.activemq.broker.TransportConnection
| ActiveMQ BrokerService[AMBRACIA] Task-2
2020-04-20 16:06:08,140 | DEBUG | Transport Connection to:
tcp://xxx.xxx.xxx.xxx:47213 failed: java.net.SocketException: Connection
reset | org.apache.activemq.broker.TransportConnection.Transport | ActiveMQ
Transport: tcp:///xxx.xxx.xxx.xxx:47213@1883



--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html

Re: Continously java.net.SocketException: Connection reset

Posted by AntonR <an...@volvo.com>.
You might have some luck trying the "keepAlive" option detailed here:
http://activemq.apache.org/tcp-transport-reference if the connection is
getting terminated by the haproxy for some reason.

Br,
Anton



--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html

Re: Continously java.net.SocketException: Connection reset

Posted by Tim Bain <tb...@alumni.duke.edu>.
You're right, I re-read the log and you did provide the broker logs. Sorry
for the confusion.

I assume the client logs show something similar for the root cause (even
though it'll be a different stack trace)?

Unfortunately I don't have any experience configuring or troubleshooting
HAProxy. I recommend you post a question asking about the HAProxy aspect of
the problem (including logs from HAProxy) to StackOverflow or
https://discourse.haproxy.org/ to ask for help from people who do know it.
If that turns up anything ActiveMQ-related, you can of course come back to
this thread to ask about it.

Good luck, and sorry that I don't have experience with HAProxy to be able
to help further.

Tim

On Thu, Apr 23, 2020, 9:50 AM JJ <ge...@euronet.aero> wrote:

> No. The connection established using localhost is working as expected.
> The question is how to configure HAProxy properly? I just used the old
> configuration working with Activemq 5.15.3
> The broker log is the one I have already posted, isn't it? Is there another
> specific log?If yes I do not know how to enable it. I will check.
>
>
>
> --
> Sent from:
> http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
>

Re: Continously java.net.SocketException: Connection reset

Posted by JJ <ge...@euronet.aero>.
No. The connection established using localhost is working as expected.
The question is how to configure HAProxy properly? I just used the old
configuration working with Activemq 5.15.3
The broker log is the one I have already posted, isn't it? Is there another
specific log?If yes I do not know how to enable it. I will check.



--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html

Re: Continously java.net.SocketException: Connection reset

Posted by Tim Bain <tb...@alumni.duke.edu>.
I hadn't understood that the connection was initially successful and data
passes correctly at first, so thank you for clarifying that.

Do you see the same behavior if you connect directly to the broker without
going through the HAProxy? Might this be introduced by the loan balancer,
possibly due to it terminating the connection due to inactivity?

Also, can you show us the broker logs from the corresponding time period?

Tim

On Tue, Apr 21, 2020, 9:18 AM JJ <ge...@euronet.aero> wrote:

> Sorry but iI do not understand what you mean.
> The clients regularly estabilish the connection, subscribe and publish. But
> after some seconds they are disconnected and I found a lot af Connection
> reset server/broker side.
>
> I use the same configuration fo years, but with an older Activemq version.
> I'd like to know, if the latest version needs different configuration, or
> better to say, if there is a worlonk configuration for the underlined
> scenario.
>
> Thank you
>
>
>
> --
> Sent from:
> http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
>

Re: Continously java.net.SocketException: Connection reset

Posted by JJ <ge...@euronet.aero>.
Sorry but iI do not understand what you mean.
The clients regularly estabilish the connection, subscribe and publish. But
after some seconds they are disconnected and I found a lot af Connection
reset server/broker side.

I use the same configuration fo years, but with an older Activemq version.
I'd like to know, if the latest version needs different configuration, or
better to say, if there is a worlonk configuration for the underlined
scenario.

Thank you 



--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html

Re: Continously java.net.SocketException: Connection reset

Posted by Tim Bain <tb...@alumni.duke.edu>.
What URI (without the HAProxy IP, of course) are you using in your MQTT
client? It's OK/expected that the underlying protocol be TCP at the network
level, but the client needs to be specifying mqtt:// in the URI to tell the
client library to use MQTT over TCP instead of OpenWire over TCP. It also
needs to be connecting to the MQTT port (1883, according to your last
message).

Tim

On Tue, Apr 21, 2020, 3:58 AM JJ <ge...@euronet.aero> wrote:

> I forgot to write that Activemq is behind HAProxy as pfsense plugin.
> The client MQTT connects to the the public pfsense WAN->nat to VIP -> VIP
> is
> HAProxy frontend -> backend with one server.
>
> HAproxy frontend is set as tcp. ActiveMQ listen on:
>       <transportConnector name="openwire"
> uri="tcp://
> 0.0.0.0:61616?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600
> "
> />
>       <transportConnector name="amqp"
> uri="amqp://
> 0.0.0.0:5672?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600
> "
> />
>       <transportConnector name="stomp"
> uri="stomp://
> 0.0.0.0:61613?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600
> "
> />
>       <transportConnector name="mqtt"
> uri="mqtt://
> 0.0.0.0:1883?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600
> "
> />
>       <transportConnector name="ws"
> uri="ws://
> 0.0.0.0:61614?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600
> "
> />
>
>
>
> --
> Sent from:
> http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
>

Re: Continously java.net.SocketException: Connection reset

Posted by JJ <ge...@euronet.aero>.
I forgot to write that Activemq is behind HAProxy as pfsense plugin.
The client MQTT connects to the the public pfsense WAN->nat to VIP -> VIP is
HAProxy frontend -> backend with one server.

HAproxy frontend is set as tcp. ActiveMQ listen on:
      <transportConnector name="openwire"
uri="tcp://0.0.0.0:61616?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"
/>
      <transportConnector name="amqp"
uri="amqp://0.0.0.0:5672?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"
/>
      <transportConnector name="stomp"
uri="stomp://0.0.0.0:61613?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"
/>
      <transportConnector name="mqtt"
uri="mqtt://0.0.0.0:1883?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"
/>
      <transportConnector name="ws"
uri="ws://0.0.0.0:61614?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"
/>



--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html

Re: Continously java.net.SocketException: Connection reset

Posted by Tim Bain <tb...@alumni.duke.edu>.
From the logs, it looks like the URI used for your connection is using
tcp:// as the transport protocol, whereas an MQTT connection use mqtt://.
And is the port you're connecting to running the MQTT protocol, or is it an
OpenWire port?

Tim

On Mon, Apr 20, 2020, 10:02 AM JJ <ge...@euronet.aero> wrote:

> Simple MQTT connection produce continously errors, and after few seconds
> client disconnection.
>
> activemq.xml is the default one.
>
> Any help/hint?
>
> java.net.SocketException: Connection reset
>         at java.base/java.net
> .SocketInputStream.read(SocketInputStream.java:186)[:]
>         at java.base/java.net
> .SocketInputStream.read(SocketInputStream.java:140)[:]
>         at
>
> org.apache.activemq.transport.tcp.TcpBufferedInputStream.fill(TcpBufferedInputStream.java:50)[activemq-client-5.15.12.jar:5.15.12]
>         at
>
> org.apache.activemq.transport.tcp.TcpTransport$2.fill(TcpTransport.java:634)[activemq-client-5.15.12.jar:5.15.12]
>         at
>
> org.apache.activemq.transport.tcp.TcpBufferedInputStream.read(TcpBufferedInputStream.java:59)[activemq-client-5.15.12.jar:5.15.12]
>         at
>
> org.apache.activemq.transport.tcp.TcpTransport$2.read(TcpTransport.java:619)[activemq-client-5.15.12.jar:5.15.12]
>         at java.base/java.io
> .DataInputStream.readByte(DataInputStream.java:270)[:]
>         at
>
> org.apache.activemq.transport.mqtt.MQTTWireFormat.unmarshal(MQTTWireFormat.java:86)[activemq-mqtt-5.15.12.jar:5.15.12]
>         at
>
> org.apache.activemq.transport.tcp.TcpTransport.readCommand(TcpTransport.java:240)[activemq-client-5.15.12.jar:5.15.12]
>         at
>
> org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:232)[activemq-client-5.15.12.jar:5.15.12]
>         at
>
> org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:215)[activemq-client-5.15.12.jar:5.15.12]
>         at java.base/java.lang.Thread.run(Thread.java:834)[:]
> 2020-04-20 16:06:07,128 | DEBUG | Unregistering MBean
>
> org.apache.activemq:type=Broker,brokerName=AMBRACIA,connector=clientConnectors,connectorName=mqtt,connectionViewType=remoteAddress,connectionName=tcp_//xxx.xxx.xxx.xxx_47203
> | org.apache.activemq.broker.jmx.ManagementContext | ActiveMQ Transport:
> tcp:///xxx.xxx.xxx.xxx:47203@1883
> 2020-04-20 16:06:07,128 | DEBUG | Stopping connection:
> tcp://xxx.xxx.xxx.xxx:47203 |
> org.apache.activemq.broker.TransportConnection
> | ActiveMQ BrokerService[AMBRACIA] Task-2
> 2020-04-20 16:06:07,129 | DEBUG | Stopping transport
> tcp:///xxx.xxx.xxx.xxx:47203@1883 |
> org.apache.activemq.transport.tcp.TcpTransport | ActiveMQ
> BrokerService[AMBRACIA] Task-2
> 2020-04-20 16:06:07,129 | DEBUG | Initialized TaskRunnerFactory[ActiveMQ
> Task] using ExecutorService:
> java.util.concurrent.ThreadPoolExecutor@113c1ae6[Running, pool size = 0,
> active threads = 0, queued tasks = 0, completed tasks = 0] |
> org.apache.activemq.thread.TaskRunnerFactory | ActiveMQ
> BrokerService[AMBRACIA] Task-2
> 2020-04-20 16:06:07,130 | DEBUG | Closed socket
> Socket[addr=/xxx.xxx.xxx.xxx,port=47203,localport=1883] |
> org.apache.activemq.transport.tcp.TcpTransport | ActiveMQ Task-1
> 2020-04-20 16:06:07,131 | DEBUG | Forcing shutdown of ExecutorService:
> java.util.concurrent.ThreadPoolExecutor@113c1ae6[Running, pool size = 1,
> active threads = 0, queued tasks = 0, completed tasks = 1] |
> org.apache.activemq.util.ThreadPoolUtils | ActiveMQ BrokerService[AMBRACIA]
> Task-2
> 2020-04-20 16:06:07,131 | DEBUG | Stopped transport:
> tcp://xxx.xxx.xxx.xxx:47203 |
> org.apache.activemq.broker.TransportConnection
> | ActiveMQ BrokerService[AMBRACIA] Task-2
> 2020-04-20 16:06:07,132 | DEBUG | Connection Stopped:
> tcp://xxx.xxx.xxx.xxx:47203 |
> org.apache.activemq.broker.TransportConnection
> | ActiveMQ BrokerService[AMBRACIA] Task-2
> 2020-04-20 16:06:08,140 | DEBUG | Transport Connection to:
> tcp://xxx.xxx.xxx.xxx:47213 failed: java.net.SocketException: Connection
> reset | org.apache.activemq.broker.TransportConnection.Transport | ActiveMQ
> Transport: tcp:///xxx.xxx.xxx.xxx:47213@1883
>
>
>
> --
> Sent from:
> http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
>