K
K
Kirill Belash2019-09-22 18:48:39
JavaScript
Kirill Belash, 2019-09-22 18:48:39

Need help with websockets?

Hello. There is a project. Requires the implementation of a chat on web sockets, but the project I have on a regular hosting. And I decided to make a server on NodeJS separately on VPS. And everything would be fine, and the sockets work and clings to the database with the help of a node and receives data. But the project uses a domain with HTTPS, and vps is only http and they are not friendly in any way. Tried from http to http - everything is ok. Same with https. But he doesn’t want to do anything different.
So var socket = new WebSocket("ws://javascript.ru"); - does not work because the site sits on https
So var socket = new WebSocket("wss://javascript.ru"); - does not connect because vps https
What to do I don’t know, transferring the project to vps is not an option.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shvets, 2019-09-22
@Xuxicheta

You need to solve the problem from the other end. You can organize https to vps
C http to https.
https://letsencrypt.org/ru/getting-started/
https://losst.ru/kak-poluchit-sertifikat-let-s-encrypt
https://www.npmjs.com/package/ws#external-https -server
Since there is still a call from one domain to another, you need to take care of CORS

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question