Reputation: 53
I am not able to use OpenFire server through WebSockets. This is the code client side I use to connect to the server:
var ws = new WebSocket('ws://35.228.94.32:7070/ws-xmpp');
ws.onopen = () => {
// connection opened
console.log('open')
};
ws.onmessage = (e) => {
// a message was received
console.log(e.data);
};
ws.onerror = (e) => {
// an error occurred
console.log("Error occured", e, e.message);
};
ws.onclose = (e) => {
// connection closed
console.log("Closing: ", e);
};
This is the error I receive:
Error occured {"isTrusted": false, "message": "failed to connect to /35.228.94.32 (port 7070) from /192.168.232.2 (port 54028) after 10000ms"} failed to connect to /35.228.94.32 (port 7070) from /192.168.232.2 (port 54028) after 10000ms
Closing: {"isTrusted": false, "message": "failed to connect to /35.228.94.32 (port 7070) from /192.168.232.2 (port 54028) after 10000ms"}
I think it is a problem of OpenFire with websockets because if I try using xmpp protocol, it works. Can you help me?
Upvotes: 1
Views: 903
Reputation: 69
http://localhost:9090/index.jsp
Server > Server Manager > Server Information > then Server Ports
:-1. HTTP Binding >> for example The port used for unsecured HTTP client connections: 7071
ws://localhost:7071/ws
2. HTTP Binding >> for example The port used for secured HTTP client connections: 7071
wss://localhost:7444/ws
Upvotes: 0
Reputation: 53
I've found the problem and it was not related to OpenFire. I run OpenFire on a Google Cloud machine and, by default, Google uses a firewall to block incoming requests. Hence, allowing requests to port 7070, it works.
Upvotes: 0
Reputation: 3006
Your endpoint does not seem correct. Try this instead:
ws://35.228.94.32:7070/ws
Optionally, if you want to use encryption, use:
wss://35.228.94.32:7443/ws
You will need to have set up proper certificates for that to work though.
Upvotes: 4