A
A
atomos902018-03-17 19:40:15
PHP
atomos90, 2018-03-17 19:40:15

How to migrate from ws to wss?

On the client side, there is a js script that uses websocket (ws). There is a php daemon on the server side, which is a websocket server (listens on "tcp://0.0.0.0:8080"). The site has been switched from http to https, respectively, you need to switch to wss, otherwise the error will occur: The page at ' https://website ' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint 'ws://server:8080 /'. This request has been blocked; this endpoint must be available over WSS.
Is it possible to make the transition "with little bloodshed" by correcting handshake / replacing tcp with ssl / adding the right one, or is it easier to use Ratchet or other libraries?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
Boris Syomov, 2018-03-17
@atomos90

The simplest thing is to terminate tls / ssl on some nginx, and then proxy requests to where they were processed. More details can be found in the nginx documentation: https://nginx.ru/ru/docs/http/websocket.html

A
atomos90, 2018-03-19
@atomos90

Found a simple working solution, PHP sockets don't work on wss://. How to fix?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question