我在Symfony中使用Gos Web Socket Bundle,我嘗試在demo they give中工作。我很迷惑關於端口,因爲它的工作原理,如果端口127.0.0.1:1337
但是當我運行的symfony的服務器時,它產生127.0.0.1:8000
,所以我嘗試添加在這裏」Websocket在服務器中不工作127.0.0.1:8000
gos_web_socket:
server:
port: 8000 #The port the socket server will listen on
host: 127.0.0.1 #The host ip to bind to
router:
resources:
- '@AppBundle/Resources/config/pubsub/routing.yml'
,並在JavaScript中的WebSocket
var websocket = WS.connect("ws://127.0.0.1:8000");
當我把它顯示在我的頁面上的時候。我總是得到不好的要求。但如果我使用WS.connect("ws://127.0.0.1:1337");
它可以工作,而我從symfony運行的服務器是127.0.0.1:8000
。我會很高興,如果你解釋爲什麼我需要使用1337端口的原因比8000
您不必強制使用端口1337,只是在服務器中打開的端口和/或防火牆;可能8000端口沒有打開。 – Triby