Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebSocket connection to 'ws://127.0.0.1:7778/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED #11

Closed
umairali opened this issue Dec 28, 2014 · 26 comments

Comments

@umairali
Copy link

Hi

i am facing this issue in browser please suggest any thing

WebSocket connection to 'ws://127.0.0.1:7778/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED

@umairali
Copy link
Author

i am using centos 7

@assertchris
Copy link
Owner

Have you started the socket server?

@umairali
Copy link
Author

On localhost (windows 8.1) when i use this command

php artisan chat:serve

connection successfull but when i use this code on my domain (Centos 7) i m facing error

@umairali
Copy link
Author

screenshot
capture2

@assertchris
Copy link
Owner

  • This line can have an IP address (of the server) following $port
  • The server firewall needs to allow connections through port 7778
  • The client firewall needs to allow connections through port 7778

@assertchris
Copy link
Owner

The JavaScript you are running (on the CentOS client browser) is trying to connect to 127.0.0.1:7778 but the server is not on the same machine. You need to adjust the JavaScript to reflect the IP address of the server (in addition to the steps suggested above).

@umairali
Copy link
Author

you have any idea how to open port 7778 on centos 7

@assertchris
Copy link
Owner

Change the IP address (in the JS) first. I have a feeling you might not need to fiddle with port settings yet.

TL;DR

no

@umairali
Copy link
Author

i already change ip address in js file but still the same error

@assertchris
Copy link
Owner

ok, next; add the IP address to that line: $port, '[your server ip]'...

Also be sure to update the JS accordingly.

@assertchris
Copy link
Owner

yes

@umairali
Copy link
Author

ok

@umairali
Copy link
Author

is this correct?

    $server = IoServer::factory(
        new HttpServer(
            new WsServer(
                $this->chat
            )
        ),
        $port, '104.125.50.52'
    );

@umairali
Copy link
Author

I am trying both
$port, '104.125.50.52'
and
$port, '[104.125.50.52]'
but still the same issue

@assertchris
Copy link
Owner

Without the brackets.

Then I fear it might be a security issue (related to firewall blocking 7778). Best google something like "unblock ports in CentOS"...

@umairali
Copy link
Author

but in my server no firewall install

i try this command for open firewall port

firewall-cmd --zone=dmz --add-port=7778/tcp --permanent

result

FirewallD is not running

@assertchris
Copy link
Owner

Your server is Windows 8.1 and your client is CentOS 7. Both have built-in firewalls. Ever run a game that minimised to show you a Windows dialog; which asked you to enable network connections for the game? That's the firewall.

@umairali
Copy link
Author

My pc is Windows 8.1 and my server CentOS 7. ok i understand.

@assertchris
Copy link
Owner

Good luck! Let me know if you figure out what the problem is and I may update the article to reflect your solution.

@umairali
Copy link
Author

i received answer from my support hosting

Your port 7778 is open, however, nothing is listening on that port and on the public interface:

$ nmap -Pn -p 7778 104.125.50.52

Starting Nmap 6.47 ( http://nmap.org ) at 2014-12-28 08:50 CST
Nmap scan report for 104.125.50.52
Host is up (0.068s latency).
PORT STATE SERVICE
7778/tcp closed interwise

Nmap done: 1 IP address (1 host up) scanned in 0.21 seconds

@yesman0319
Copy link

看不懂 - -||

@stevengpn
Copy link

make sure the server listening IP is 0.0.0.0 instead of 127.0.0.1

@hugoofab
Copy link

maybe yesman0319 brings the definitive response but, someone can read it?

@kairat-beep
Copy link

i can't understand what i see- translating explicitly." with some <- -||> i have no idea what is that"

@assertchris
Copy link
Owner

Folks, this is an old issue, and an even older tutorial. If you would like to discuss over twitter (and with a link to some code you are working on at the time), then I can help try to debug there. In the meantime, I'm going to lock this thread.

Repository owner locked and limited conversation to collaborators Feb 20, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants