简体   繁体   English

Websocket - WebSocket 握手期间出错:意外的响应代码:404

[英]Websocket - Error during WebSocket handshake: Unexpected response code: 404

I am using websocket in my app and everything worked fine when i was using localhost.我在我的应用程序中使用 websocket,当我使用 localhost 时一切正常。 The problem starts when i changed localhost to my server ip address then i got this error: Error during WebSocket handshake: Unexpected response code: 404当我将 localhost 更改为我的服务器 IP 地址时,问题就开始了,然后出现此错误: WebSocket 握手期间出错:意外的响应代码:404

This is my httpd.conf这是我的 httpd.conf

...

Listen 25.48.63.220:80
Listen 25.48.63.220:8081

...

ServerName 25.48.63.220:80

...

I think that i am able to connect with my server because when i typed wrong ip address i don't get this error.我认为我能够连接到我的服务器,因为当我输入错误的 IP 地址时,我没有收到此错误。

What else i have to to change ?我还需要改变什么?

404 means Not Found. 404 表示未找到。 Probably you are connecting to the wrong place, or you didn't map the port from your public IP address to your local IP address.可能您连接到错误的位置,或者您没有将端口从公共 IP 地址映射到本地 IP 地址。

I solved this problem.我解决了这个问题。 If you are using composer to download Ratchet you need to change constructor in /vendor/cboden/ratchet/src/Ratchet/App.php.如果您使用 composer 下载 Ratchet,您需要更改 /vendor/cboden/ratchet/src/Ratchet/App.php 中的构造函数。

Default __construct should look like this:
 public function __construct($httpHost = 'localhost', $port = 80, $address = 'localhost', LoopInterface $loop = null) {

So you only need to change httpHost, port and address.所以你只需要更改httpHost、端口和地址。 It works for me :)这个对我有用 :)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 javascript-WebSocket握手期间错误:意外的响应代码:404 - javascript - Error during WebSocket handshake: Unexpected response code: 404 WebSocket连接到 <url> 失败:WebSocket握手期间出错:意外的响应代码:404 - WebSocket connection to <url> failed: Error during WebSocket handshake: Unexpected response code: 404 与&#39;wss:// localhost:44300 / Home / websocketcon&#39;的WebSocket连接失败:WebSocket握手期间出错:意外响应代码:404 - WebSocket connection to 'wss://localhost:44300/Home/websocketcon' failed: Error during WebSocket handshake: Unexpected response code: 404 Websocket:WebSocket握手期间出错:意外的响应代码:504 - Websocket : Error during WebSocket handshake: Unexpected response code: 504 WebSocket握手:意外的响应代码:404 - - WebSocket handshake: Unexpected response code: 404 - WebSocket 握手:意外响应代码:404 - WebSocket handshake: Unexpected response code: 404 Tomcat 7 Websocket握手:意外的响应代码:404 - Tomcat 7 Websocket handshake: Unexpected response code: 404 尝试连接到服务器时..失败:WebSocket 握手期间出错:意外响应代码:404 - when trying connecting to server.. failed: Error during WebSocket handshake: Unexpected response code: 404 Sailsjs:WebSocket握手期间出错:意外的响应代码:400 - Sailsjs: Error during WebSocket handshake: Unexpected response code: 400 WebSocket 握手期间出错:意外的响应代码:500 - Error during WebSocket handshake: Unexpected response code: 500
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM