Jump to content

Why does socket server no longer accept remote connections?


Go to solution Solved by kicken,

Recommended Posts

Finally bit the bullet and migrated to PHP7 as well as Centos7.

 
Unfortunately, remote clients can no longer connect to my sockets server.
 
A client running on the same machine, however, can connect using both 1.2.3.4:1337 as well as 1.2.3.4:1337 (where 1.2.3.4 is the server's IP).
 
I've disabled the firewall just in case, but still cannot connect.  Originally, I was using SSL, but I stripped that all off, and am just using TCP.
 
I don't know if it is related, but the server doesn't respond to pings unless made from its machine, however, Apache will respond to curl 1.2.3.4.
 
What should I investigate?  Thanks!

EDIT.  I just found out I can connect on port 80.  Why just port 80?

 

If it helps, this is my test script.  The client can only connect when run on the same machine.

<?php
$host='0.0.0.0:1337';
error_reporting(E_ALL);
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
openlog('API', LOG_NDELAY, LOG_LOCAL2);


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


$loop = \React\EventLoop\Factory::create();
$server = new \React\Socket\TcpServer($host, $loop);
$server->on('connection', function (\React\Socket\ConnectionInterface $conn) {
    syslog(LOG_INFO,"onConnect");
    $conn->on('data', function($data) {
        syslog(LOG_INFO,"onData");
        var_dump($data);
    });
    $conn->on('error', function($error, $conn) {
        syslog(LOG_INFO,"onError");
        var_dump($error);
    });
    $conn->on('close', function() {
        syslog(LOG_INFO,"onClose");
    });
});
$server->on('error', function($error) use ($loop){
    $this->logError('onServerError: '.$error->getMessage(), $data);
    //$loop->stop();
});
$loop->run();
<?php
$host='1.2.3.4:1337';
error_reporting(E_ALL);
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
openlog('API', LOG_NDELAY, LOG_LOCAL2);


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


$loop = \React\EventLoop\Factory::create();
$connector = new \React\Socket\TimeoutConnector(new \React\Socket\Connector($loop), 5, $loop);
$connector->connect($host)
->then(function (\React\Socket\ConnectionInterface $conn)  use ($loop) {
    syslog(LOG_INFO,"onConnect");
    $conn->on('data', function($data) {
        syslog(LOG_INFO,"onData");
        var_dump($data);
    });
    $conn->on('error', function($error, $conn) {
        syslog(LOG_INFO,"onError");
        var_dump($error);
    });
    $conn->on('close', function() {
        syslog(LOG_INFO,"onClose");
    });
})->otherwise(function(\RuntimeException $error) use(&$response, $loop){
    syslog(LOG_INFO,"onTimeout");
});
$loop->run();
Edited by NotionCommotion
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.