Issue creating WebSocket Connection via Mosquitto broker - websocket

Mosquitto broker version 1.5.9
WebSocket support enabled and built
Port 9001 is opened on the broker
OS Amazon Linux 2 AMI (Fedora)
mosquitto_conf
port 1883
listener 9001
protocol websockets
==========================================================
1592388049: mosquitto -c /etc/mosquitto/mosquitto.conf
1592388049: mosquitto version 1.5.9 starting
1592388049: Config loaded from /etc/mosquitto/mosquitto.conf.
1592388049: |-- *** auth-plug: startup
1592388049: |-- ** Configured order: mysql
1592388049: |-- }}}} MYSQL
1592388049: |-- SSL is disabled
1592388049: Opening websockets listen socket on port 9001.
1592388049: Opening ipv4 listen socket on port 1883.
1592388049: Opening ipv6 listen socket on port 1883.
However when I try to connect to the broker via websocket using a simple Paho Javascript program, I get the following error:
mqttws31.js:977 WebSocket connection to 'ws://x.x.x.x:9001/mqtt'
failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
Connection failed: AMQJSC0001E Connect timed out.Retrying

Related

Log4j2 socket appender inside a docker container throw connection refused

I have a springboot app running on docker container. In my app there is a log4j.xml file with socket appender.
<Socket name="Socket" host="172.17.0.1" port="5100">
<JsonLayout compact="true" eventEol="true" />
</Socket>
In my host server (Ubuntu server) its listing port 5100 by logstash. Out put of "netstat -tulpn" command in host is as below.
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:8280 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:5100 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:5001 0.0.0.0:* LISTEN -
But when the springboot server up its getting connection refused error.
2021-07-30 05:20:47,646 main ERROR TcpSocketManager (TCP:172.17.0.1:5100) caught exception and will continue: java.net.ConnectException: Connection refused (Connection refused)
at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
I tried with "host.docker.internal" also and its not working. Can anyone let me know what is the problem with this please?
As you can see from your netstat output, Logstash is listening on 127.0.0.1:5100 only. That means it cannot be accessed from within Docker. You have to make it listen on 172.17.0.1:5100 or 0.0.0.0:5100.

Loop for assign the ports number to tomcat nodes

I would like to create a script to create a certain number of Tomcat nodes and automatically assign shutdown, HTTP and ajp ports as the following schema:
tomcat_a
shutdown port 8001
http port 8081
ajp port 8011
tomcat_b
shutdown port 8002
http port 8082
ajp port 8012
tomcat_n
shutdown port 8009
http port 8089
ajp port 8019
How can I do it?
Thanks

Connection Refused for Consul

I am starting a Spring Boot Application with Consul.
I am getting the following error
2019-08-30 12:34:22.650 ERROR 23428 --- [ main] o.s.boot.SpringApplication : Application run failed
com.ecwid.consul.transport.TransportException: org.apache.http.conn.HttpHostConnectException: Connect to localhost:8090 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect`
I changed the default port in bootstrap.properties file.
I also used another non-Consul Spring Boot Application and it worked fine for that use-case with same port.
8090 is not the default port for Consul. You didn't say if your other successful app was on the same host or not, but make sure Consul is actually listening on that port with netstat or ss.
By default, Consul listens for API requests on port 8500.

Hazelcast successfully discovers nodes but unable to connect (OrientDB)

I'm using Hazelcast in EC2 discovery mode to allow OrientDB to run in distributed mode. The nodes are running in the same security group under the same EC2 role. The plugin successfully discovers other nodes but fails to connect over ports 5701-5703. Here is the error message:
2019-05-31 19:44:45:303 INFO [10.4.31.181]:5701 [orientdb] [3.8.4] Could not connect to: /10.4.26.235:5703. Reason: SocketException[Connection timed out to address /10.4.26.235:5703] [InitConnectionTask]
I checked if any process is listening on those ports on other nodes (lsof -i -P -n) and discovered these entries
java 10023 root 91u IPv6 357165 0t0 TCP *:2424 (LISTEN)
java 10023 root 92u IPv6 357166 0t0 TCP *:2480 (LISTEN)
java 10023 root 135u IPv6 357826 0t0 TCP *:5701 (LISTEN)
It seems that all OrientDB listeners are using IPv6 although I never enabled it anywhere (there are no IPv4 listeners). How do I make it listen using IP4? Here is the only thing I changed in hazelcast.xml after I install it.
<network>
<join>
<multicast enabled="false"/>
<aws enabled="true">
<tag-key>Name</tag-key>
<tag-value>orientdb-test</tag-value>
</aws>
</join>
</network>

JBoss - ExportException: Port already in use: 1098

I'm getting the following error when I try to start JBoss
10:10:43,298 INFO [WebService] Using RMI server codebase: http://127.0.0.1:8083/
10:10:43,938 ERROR [AbstractKernelController] Error installing to Start: name=jboss:service=Naming state=Create mode=Manual requiredState=Installed
java.rmi.server.ExportException: Port already in use: 1098; nested exception is:
java.net.BindException: Address already in use: JVM_Bind
at sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:249)
at sun.rmi.transport.tcp.TCPTransport.exportObject(TCPTransport.java:184)
at sun.rmi.transport.tcp.TCPEndpoint.exportObject(TCPEndpoint.java:382)
at sun.rmi.transport.LiveRef.exportObject(LiveRef.java:116)
at sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:180)
at java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.java:293)
at java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.java:256)
However When I try to see what ports are being listened to. I don't see that port!
H:\>netstat -a -n -o
Active Connections
Proto Local Address Foreign Address State PID
TCP 0.0.0.0:135 0.0.0.0:0 LISTENING 824
TCP 0.0.0.0:445 0.0.0.0:0 LISTENING 4
TCP 0.0.0.0:1521 0.0.0.0:0 LISTENING 2036
TCP 0.0.0.0:3389 0.0.0.0:0 LISTENING 752
TCP 0.0.0.0:7717 0.0.0.0:0 LISTENING 2944
TCP 0.0.0.0:8081 0.0.0.0:0 LISTENING 1564
TCP 0.0.0.0:31038 0.0.0.0:0 LISTENING 1436
TCP 127.0.0.1:1038 0.0.0.0:0 LISTENING 2036
TCP 127.0.0.1:1052 0.0.0.0:0 LISTENING 2620
TCP 127.0.0.1:5998 127.0.0.1:5999 ESTABLISHED 4036
TCP 127.0.0.1:5999 127.0.0.1:5998 ESTABLISHED 4036
TCP 127.0.0.1:6000 127.0.0.1:6001 ESTABLISHED 4036
TCP 127.0.0.1:6001 127.0.0.1:6000 ESTABLISHED 4036
TCP 142.174.27.74:139 0.0.0.0:0 LISTENING 4
TCP 142.174.27.74:13148 142.174.12.84:445 ESTABLISHED 4
TCP 142.174.27.74:13253 142.174.134.33:8080 ESTABLISHED 4036
TCP 142.174.27.74:13255 142.174.134.33:8080 ESTABLISHED 4036
TCP 142.174.27.74:13258 142.174.134.33:8080 ESTABLISHED 4036
TCP 142.174.27.74:13259 142.174.134.33:8080 ESTABLISHED 4036
TCP 142.174.27.74:13260 142.174.134.33:8080 ESTABLISHED 4036
TCP 142.174.27.74:13261 142.174.134.33:8080 ESTABLISHED 4036
TCP 142.174.27.74:13262 142.174.134.33:8080 ESTABLISHED 4036
TCP 142.174.27.74:13263 142.174.134.33:8080 ESTABLISHED 4036
UDP 0.0.0.0:445 *:* 4
UDP 0.0.0.0:8081 *:* 1564
UDP 0.0.0.0:8082 *:* 1564
UDP 0.0.0.0:19508 *:* 1244
UDP 127.0.0.1:123 *:* 948
UDP 127.0.0.1:1025 *:* 580
UDP 127.0.0.1:1046 *:* 524
UDP 127.0.0.1:1056 *:* 784
UDP 127.0.0.1:1213 *:* 2888
UDP 127.0.0.1:1257 *:* 2404
UDP 127.0.0.1:2172 *:* 3736
UDP 127.0.0.1:2310 *:* 2188
UDP 142.174.27.74:123 *:* 948
UDP 142.174.27.74:137 *:* 4
UDP 142.174.27.74:138 *:* 4
H:\>
any ideas?
Thanks,
Tam
Try TCPView (TCPView v3.05). I get this "port already in use" quite a lot, and TCPView always usually catches the culprit.
Go to jboss-service.xml under conf folder and change the port for RMI from 1098 to 8099 8099
Restart the server .
We ran into this problem some time ago as well, not just with JBoss, but also MySQL.
I wrote about it in more detail here:
Windows TCP Port Conflicts above 1024
What it comes down to is that Windows uses the port range between 1000 and 5000 for so called "ephemeral" ports. This means that it assigns ports from this range for processes that request a random port.
On Windows 2000/2003 Server installations as well as on Windows XP Pro you can reserve port ranges (even if they only cover a single port) for your applications. Effectively they are not reserved for anything specific, but just excluded from the dynamic allocation. To do so, create or edit the following registry value (type REG_MULTI_SZ/Multi-String Value):
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\ReservedPorts
In this value specify port ranges in the format xxxx-yyyy with xxxx and yyyy being the lowest and highest port of the range to be reserved. To reserve a single port, just use the same values for both (e. g. 1099).
I guess that port is still in use. You can find that using:
netstat -ao
and
netstat -b
If you can't use that port, find another port and change it in the following XML file:
conf/bindings-beans/META-INF/bindings-jboss-beans.xml
The JBoss 5 has a new ServiceBindingManager which uses bean injection to assign ports at runtime. Changing the port here may do the trick for you.
You can also use a different ports configuration and override the ports by a factor.
Based on the ports mentioned in the file referenced by Sam, and the registry key referenced by Daniel Schneller, the following should do the trick for JBoss EAP 5:
1090-1090 1098-1102 1161-1162 3528-3528 4444-4448 4457-4457 4712-4714 5445-5446 8080-8083 8443-8443
Translated in a .reg file:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters]
"ReservedPorts"=hex(7):31,00,30,00,39,00,30,00,2d,00,31,00,30,00,39,00,30,00,\
20,00,31,00,30,00,39,00,38,00,2d,00,31,00,31,00,30,00,32,00,20,00,31,00,31,\
00,36,00,31,00,2d,00,31,00,31,00,36,00,32,00,20,00,33,00,35,00,32,00,38,00,\
2d,00,33,00,35,00,32,00,38,00,20,00,34,00,34,00,34,00,34,00,2d,00,34,00,34,\
00,34,00,38,00,20,00,34,00,34,00,35,00,37,00,2d,00,34,00,34,00,35,00,37,00,\
20,00,34,00,37,00,31,00,32,00,2d,00,34,00,37,00,31,00,34,00,20,00,35,00,34,\
00,34,00,35,00,2d,00,35,00,34,00,34,00,36,00,20,00,38,00,30,00,38,00,30,00,\
2d,00,38,00,30,00,38,00,33,00,20,00,38,00,34,00,34,00,33,00,2d,00,38,00,34,\
00,34,00,33,00,00,00,00,00
The root cause is that JBOSS was not peoperly shut down.
If you are using Windows,
go to task manager and kill the JBOSS processes.
Reserve the port 1098-1099 in registry.
Restart the oracle service if running, then start the JBOss.
This error is also thrown by Jboss if your default IP address changes due to some problem
means
121...89 to 121...90 Just check it and replace it with a newer IP address. It will work.

Resources