douzhong5902 2014-07-14 10:27
浏览 583

Websocket:无法与基本websocket服务器建立连接

I've tried very basic websocket tutorial using ratchet php, exactly as shown in http://socketo.me/docs/hello-world

Code for websocket server:

<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');

require 'vendor/autoload.php';
require 'chat.php';

use Ratchet\Server\IoServer;
use HHWS\Chat;


$server = IoServer::factory(
    new Chat(),
    8080
);

$server->run();

To run the server I did:

$ php ws-server.php

And to test the connection with the server I did:

telnet 127.0.0.1 8080

This worked perfectly fine when tested LOCALLY. Users can chat using multiple telnet terminals.

I then uploaded the code to live server. And the tried running the server. Then tried to connect to this server using telnet just like before, it couldn't connect. All it shows is "Trying.." message and then " Unable to connect to remote host: Connection timed out".

I don't know why this is happening, and what the problem is. The code is exactly the same. And this is very basic hello world example I'm doing. Can anyone help me on this. Do using "Websockets" have any other requirements on the live server to work.

Update: Actually, the live server is Amazon EC2; does this require setting up additional things for websocket to work?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥60 版本过低apk如何修改可以兼容新的安卓系统
    • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题
    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题
    • ¥15 请完成下列相关问题!
    • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?