ActiveMQ SocketException - spring

I'm running into a problem every two months or so. My activemq server dies and the log is full with SocketExceptions.
I have a PHP application using stomp to send messages to ActiveMQ and
a Java application to consume the messages.
I have activemq on another server where only java applications are used when sending/consuming messages and it has never failed like this. I think there is somthing
wrong with Stomp.
The stomp code is very basic and does not send anything odd. Only messages with message properties set. The stomp code closes the connection after every message sent.
I've looked at lsof and there is nothing out of order there.
netstat does however have alot of:
tcp6 0 0 127.0.0.1:61616 127.0.0.1:46280 CLOSE_WAIT
And the ActiveMQ Log shows alot of this
2011-04-28 12:43:09,819 | ERROR |
Could not accept connection :
java.net.SocketException: Too many
open files |
org.apache.activemq.broker.TransportConnector
| ActiveMQ Transport Server:
tcp://0.0.0.0:61616
I'm using:
ActiveMQ 5.4.2,
Tomcat 6.0.20,
Debian 5.0.3,
PHP 5.2.6,
Stomp revision 43

It seems that you are opening a lot connections in your java program, and then you are hitting your ulimit -n. Close Connections after usage or use a connection pool.
As a wourkaround you can raise your open file limit via sysctl, see a tutorial here.

Related

Mosquitto 2.0.14 with Websockets

I have a Mosquitto 2.0.14 broker running in a Windows server 2019. I can connect to it over port 8883 using mqtts protocol with SSL enabled. I can also connect to it on port 1883 without SSL.
Now I want to connect using Websockets. So I added a listener as:
listener 9001
protocol websockets
allow_anonymous false
password_file C:\mosquitto\password.txt
http_dir C:\mosquitto\http_dir
set_tcp_nodelay true
I also tried without http_dir and set_tcp_nodelay. I have tried with and without SSL certificates.
I have port 9001 opened in windows firewall as well as on AWS EC2 instance security groups.
But when I try to connect to the broker using ws://broker.mysite.com:9001 or ws://broker.mysite.com:9001/mqtt nothing happens. No error, no connection. Mosquitto does not show any logs even though I can see the request coming in using WireShark. I am really stuck here. please help me out.
Edit:
I have tried to connect using MQTTX, MQTT Explorer and MQTTBox Chrome App.
As per the comments this issue has been noted previously (in this answer), however I figure its worth repeating here to aid others who experience the problem.
In short - there appears to be a bug in Mosquitto versions 2.0.12, 2.0.13 & 2.0.14 running on Windows when listening for websocket connections. Whilst the broker appears to be listening (on the correct port) it does not, in fact, accept connections (and nothing is logged). I have not investigated in detail but the cause is going to be something about the way the socket is being configured.
There is a workaround - add socket_domain ipv4 under the listener e.g.
listener 9001
protocol websockets
allow_anonymous false
password_file C:\mosquitto\password.txt
http_dir C:\mosquitto\http_dir
set_tcp_nodelay true
socket_domain ipv4
See this issue in the github repo for more information.

Mosquitto Broker service refuses to start on websockets

I am trying to start my Eclipse Mosquitto broker service for listening to websockets adding:
listener 8083
protocol websockets
at the mosquitto.conf
If I only use listener 8083, the service starts but when protocol websockets is added, the service stops and refuses to start.
The error I get if I run:
mosquitto -v -c mosquitto.conf
is: 1588309602: Error: Unable to start any listening sockets, exiting.
The full output is:
1588309602: mosquitto version 1.6.9 starting
1588309602: Config loaded from mosquitto.conf.
1588309602: Opening websockets listen socket on port 8083.
1588309602: Error: Unable to start any listening sockets, exiting.
I am under Windows10 Pro.
Any ideas?
The answer to this:
Based on trials I can confirm that you need to mention a default port initially e.g.
port 1883
protocol mqtt
# Websockets
listener 9001
protocol websockets
if you only wish to use WebSockets for MQTT then instead of using listener 9001 you need to replace it with port 9001.
There should be atleast one default port to listen to in Mosquitto MQTT.
Verified using Mosquitto 1.6.10
I am posting an answer based on facts.
I have uninstalled version 1.6.9 and installed 1.6.7 and now the service is running using websockets...
I cannot confirm if this is an issue with 1.6.9 but this is what happened to me.
BR
According to other sources, the error lies in 1.6.10 (and perhaps others), whereby, there MUST be a standard protocol mqtt defined, otherwise websockets will not start.
Thus you can leave the standard configuration alone (port 1883) and then in the
Extra listeners section of mosquitto.conf, define the websockets listener as you like.
I believe this has been remedied in later versions, so that only websockets can be defined.
Sadly, in this case the only defense against unauthorized use of the broker over the standard mqtt socket is then the system firewall for external users. Users with ssh access can "play".
The mqtt protocol has to be enabled for the websockets to work.
As the option port (like others have mentioned) is deprecated in versions 2.x.x, you can use listener instead.
listener 1883
protocol mqtt
listener 9001
protocol websockets
And then run your mosquitto server as usual.

How to get events for kafka broker errors using confluent-kafka-go

I'm writing a producer in go, using the channel producer example of confluent-kafka-go library. When I run my app with brokers working then I get the produced events by reading from range producer.Events() .
But when the brokers are down, I get logs like the following from the kafka library printed in stderr, but I cannot find a way for my app to register for those errors so I can detect them:
%3|1528267290.204|FAIL|rdkafka#producer-1| [thrd:xxx.xxx.com:9092/bootstrap]: xxx.xxx.com:9092/bootstrap: Connect to ipv4#xxx.xxx.xxx.xxx:9092 failed: Connection refused
%3|1528267290.204|ERROR|rdkafka#producer-1| [thrd:xxx.xxx.com:9092/bootstrap]: 1/1 brokers are down
How can I receive those events from the library ? To clarify I'm interested in errors like RD_KAFKA_RESP_ERR__FAIL described in the docs
It seems there was no way to receive the errors, I have opened an issue and the fix will be released soon in v0.11.5:
https://github.com/confluentinc/confluent-kafka-go/issues/200

How to check if MQ is connected

I'm trying to connect to my MQ servers. I have 2 MQ Server: server 1 and server 2 and set it as connectionNameList for mqConnectionFactory. Is there a way for MQ to connect to server 1 if server 2 failed? How can I know if MQ server is connected? I saw that there is clientReconnectOptions set to 67108864 but I'm not sure what is that.
The possible settings for ClientReconnectOptions are documented in the IBM MQ Knowledge center page CLIENTRECONNECTOPTIONS
Below is an example using setClientReconnectOptions to set it so the application can reconnect to any queue manager listing on the two host(port) combinations set in the connectionNameList.
MQQueueConnectionFactory factory = new MQQueueConnectionFactory();
factory.setQueueManager("QMNAME");
factory.setChannel("SVRCONN.CHL");
factory.setConnectionNameList("hostName1(port),hostName2(port)");
factory.setClientReconnectOptions( WMQConstants.WMQ_CLIENT_RECONNECT );
// Set the amount of time you will attempt to reconnect in seconds
factory.setClientReconnectTimeout( 43200 ); //12 hours
//default is 1800 seconds
//factory.setClientReconnectTimeout(WMQConstants.WMQ_CLIENT_RECONNECT_TIMEOUT_DEFAULT);
Note that clients will not always attempt to reconnect, see the following from the endmqm man page on Linux:
If you issue endmqm to stop a queue manager, reconnectable clients do
not try to reconnect. To override this behavior, specify either the -r
or -s option to enable clients to start trying to reconnect.
Note: If a queue manager or a channel ends unexpectedly, reconnectable
clients start trying to reconnect.

Remote JMS client cant connect to the HornetQ (which is embedded with jboss 7.1.1 as)

When standalone client and jboss server runs on the same machine, everything works fine, but when i try to run the JBoss on a VM, i can get a JNDIContext from the Server,i can do a successful lookup, but i cannot establish a connection.
The Client throwing an exception as:
Exception in thread "main" javax.jms.JMSException: Failed to create session factory
at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:605)
at #org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:119)
...
Caused by: HornetQException[errorCode=2 message=Cannot connect to server(s). Tried with all available servers.]
at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:769)
at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:601)
... 2 more
And the server End showing msg as,
JBAS011806: Channel end notification received, closing channel Channel ID 459d0f32 (inbound) of Remoting connection 00e9212a to /192.168.35.29:42179
I have seen other posts also related to this issue , but I didnt clear with the solution . So Plz help me out and forgive me If I am asking silly question since I am new in this domain.
Thanks.
You have to configure the port on the server. You probably have the server starting as localhost and you are connecting externally, in such way the JNDI can connect but not the HornetQ connector.
You certainly have a configuration error, but without knowing version, what actual message you got and configuration options I have little information to help you more beyond that.

Resources