ratchetphp / Ratchet

Asynchronous WebSocket server
http://socketo.me
MIT License
6.24k stars 727 forks source link

I connected Ratchet server on hosting site, but when I paste JavaScript code I get an error. #803

Closed Brian1111 closed 4 years ago

Brian1111 commented 4 years ago

I could run Ratchet server on my shared hosting site on GoDaddy terminal. Attached is the screenshot:

cPanel_server_started

But when I paste the JavaScript code to Chrome console, I get an error message. Attached are the screenshots:

Chrome_console_error Chrome_console_error2

You can check it for yourself at the following link:

http://pika4.com/ratchet_hello_world2/

cboden commented 4 years ago

Have you configured your hosting's security to allow port 8000 to be open? Most hosting providers block everything except port 80 and 443 by default.

Brian1111 commented 4 years ago

It runs on port 8080. Apparently GoDaddy hasn't blocked port 8080 because it says server connected and I am not getting any error message. What is your opinion?

I tried to run it on a subdomain on port 80, but it didn't work. Please clarify if I run it on port 80 do I need two servers or one server is enough? Also, if I run it on port 80, should I run it on a subdomain? Can I run it on main domain?

Also, should JavaScript websocket be WebSocket('ws://localhost:8080/echo')?

Brian1111 commented 4 years ago

Here is more info: When I don't run Ratchet server on GoDaddy, Chrome console shows an error message and network status shows nothing. However, when I run Ratchet server on GoDaddy terminal, the error on Chrome console disappears and network status becomes 200.

Brian1111 commented 4 years ago

I ran several port scanners. Apparently the only port that is open is port 80. And port 8080 is closed. I don't think I can run Ratchet on port 80 since my own program runs on port 80. So since apparently Ratchet runs on the closed port of 8080, probably my best option is to make this work. If I can't make port 8080 work, is the only option of running Ratchet and my program side by side by deploying it to a cloud hosting such as Digital Ocean or AWS?

Brian1111 commented 4 years ago

The only way to run Ratchet server is by deploying it to a cloud hosting. So I close this issue.