简体   繁体   中英

Sockets not working in AWS ec2 using PHP?

Unable to make socket.io working on AWS EC2

 https://mydoamin.com:2120/socket.io/?EIO=3&transport=polling&t=NQpMyRI net::ERR_TIMED_OUT
i.create @ socket.io.js?v=1609310849:7

Localhost everything working fine the way it should be working but on live environment, I am getting above error.

When I connect using [workerman][1] and starting it using CLI on was ubuntu instance it is working fine

Somehow ports are not working properly even I have added it in security groups under inbound settings:-

And now this error after configuring:

<?php
use kriss\webMsgSender\WebMsgSender;

return [
   'components' => [
       // others
       WebMsgSender::COMPONENT_NAME => [
           'class' => WebMsgSender::class,
           'pushApiClientHost' => '0.0.0.0',
           'logCategory' => 'webMsgSender',
       ],
   ],
];

New error

socket.io.js?v=1609310849:7 GET https://myDoamin.com:2120/socket.io/?EIO=3&transport=polling&t=NQpU3PA net::ERR_CONNECTION_RESET

Extension I am using

Make sure you configure socket io to listen to be bonded to all IP addresses, not just the localhost

so instead of

<?php
use kriss\webMsgSender\WebMsgSender;

return [
    'components' => [
        // others
        WebMsgSender::COMPONENT_NAME => [
            'class' => WebMsgSender::class,
            'pushApiClientHost' => 'localhost',
            'logCategory' => 'webMsgSender',
        ],
    ],
];

change to

<?php
use kriss\webMsgSender\WebMsgSender;

return [
    'components' => [
        // others
        WebMsgSender::COMPONENT_NAME => [
            'class' => WebMsgSender::class,
            'pushApiClientHost' => '0.0.0.0',
            'logCategory' => 'webMsgSender',
        ],
    ],
];

basically change localhost to 0.0.0.0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM