我无法通过OpenFire使用WebSockets服务器。这是我用来连接到服务器的代码客户端:
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);
};
这是我收到的错误:
错误发生{"isTrusted":false,"message":“在10000 to后从/192.168.232.2 (端口54028)连接到/35.228.94.32 (端口7070)”}在10000 to后未能从/192.168.232.2 (端口54028)连接到/35.228.94.32 (端口7070)
关闭:{"isTrusted":false,"message":“在10000 to之后,从/192.168.232.2 (端口54028)连接到/35.228.94.32 (端口7070)失败”}
我认为这是websockets的OpenFire问题,因为如果我尝试使用xmpp协议,它就能工作。你能帮帮我吗?
发布于 2020-06-01 08:29:09
您的端点似乎不正确。试一试:
ws://35.228.94.32:7070/ws
或者,如果要使用加密,请使用:
wss://35.228.94.32:7443/ws
但是,您需要设置适当的证书才能工作。
发布于 2020-06-01 10:32:23
我发现了这个问题,它与OpenFire无关。我在Google机器上运行OpenFire,默认情况下,Google使用防火墙来阻止传入的请求。因此,允许对端口7070的请求,它工作。
发布于 2021-08-19 11:56:00
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
:
https://stackoverflow.com/questions/62127972
复制相似问题