There is an application on the server, listening to port 7777 and waiting for a ws: // connection
Briefly about how it should work: Browser -> Nginx (HTTPS) -> WS Server (here we want not to use the certificate, which is why such problems)
The problem is that for some reason, when sending data to the server, only part of the messages from JS arrive:
Always comes 1 letter from the message, which is very strange. I tried to run all the same on the local Windows machine, everything works as it should.
Launched on c # using websocket-sharp
WebSocketServer srv = new WebSocketServer(7777); srv.AddWebSocketService<MyClient>("/ws");//ΡΡΠ΄Π° Π΄ΠΎΠ»ΠΆΠ΅Π½ ΠΏΠ΅ΡΠ΅Π½Π°ΠΏΡΠ°Π²Π»ΡΡΡ proxy_pass srv.Start(); Console.WriteLine("Server is listening......"); //ΠΏΡΠΎΡΡΠΎΠΉ listener Ρ Π²ΡΠ²ΠΎΠ΄ΠΎΠΌ Π΄Π°Π½Π½ΡΡ
class MyClient : WebSocketBehavior { protected override void OnOpen() { Write("Client Connected!", ConsoleColor.Green); } protected override void OnClose(CloseEventArgs e) { Write("Close connection: "+ e.Reason, ConsoleColor.Red); } protected override void OnError(ErrorEventArgs e) { Write("Error: "+e.Message, ConsoleColor.DarkRed, ConsoleColor.Gray); } protected override void OnMessage(MessageEventArgs e) { Write(e.Data); } } Simple JS client:
var socket = new WebSocket("wss://ΠΌΠΎΠΉ-ΡΠ°ΠΉΡ/Game"); socket.onopen = function() { console.log("Π‘ΠΎΠ΅Π΄ΠΈΠ½Π΅Π½ΠΈΠ΅ ΡΡΡΠ°Π½ΠΎΠ²Π»Π΅Π½ΠΎ."); activeBtns(false); }; socket.onclose = function(event) { if (event.wasClean) { console.log('Π‘ΠΎΠ΅Π΄ΠΈΠ½Π΅Π½ΠΈΠ΅ Π·Π°ΠΊΡΡΡΠΎ ΡΠΈΡΡΠΎ'); } else { console.log('ΠΠ±ΡΡΠ² ΡΠΎΠ΅Π΄ΠΈΠ½Π΅Π½ΠΈΡ'); // Π½Π°ΠΏΡΠΈΠΌΠ΅Ρ, "ΡΠ±ΠΈΡ" ΠΏΡΠΎΡΠ΅ΡΡ ΡΠ΅ΡΠ²Π΅ΡΠ° } console.log('ΠΠΎΠ΄: ' + event.code + ' ΠΏΡΠΈΡΠΈΠ½Π°: ' + event.reason); activeBtns(true); }; socket.onmessage = function(event) { console.log("ΠΠΎΠ»ΡΡΠ΅Π½Ρ Π΄Π°Π½Π½ΡΠ΅ "); console.log(event.data); }; socket.onerror = function(error) { console.log("ΠΡΠΈΠ±ΠΊΠ° " + error.message); activeBtns(true); }; activeBtns(); sendData = function(){ socket.send("test message"); }; On the server (OS: Ubuntu) there is Nginx with settings (installed clean v1.14.1):
user www-data; worker_processes auto; pid /run/nginx.pid; include /etc/nginx/modules-enabled/*.conf; events { worker_connections 768; # multi_accept on; } http { sendfile on; keepalive_timeout 604800; proxy_connect_timeout 604800; proxy_send_timeout 604800; proxy_read_timeout 604800; include /etc/nginx/mime.types; default_type application/octet-stream; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; } #ΠΊΠΎΠ½ΡΠΈΠ³ ΠΌΠΎΠ΅Π³ΠΎ Π΄ΠΎΠΌΠ΅Π½Π°: server { listen 443 ssl; server_name ΠΌΠΎΠΉ-ΡΠ°ΠΉΡ; #ΡΡΡ ΠΌΠΎΠΉ Π΄ΠΎΠΌΠ΅Π½ access_log /etc/nginx/logs/log.access; error_log /etc/nginx/logs/log.error error; ssl on; ssl_certificate /etc/ssl/certs/cert.pem; ssl_certificate_key /etc/ssl/private/cert.key; client_max_body_size 1M; client_body_buffer_size 1M; location / { root /var/www/ΠΌΠΎΠΉ-ΡΠ°ΠΉΡ/html; index index.html index.htm; } location /Game { proxy_pass http://ΠΌΠΎΠΉ-ΡΠ°ΠΉΡ:7777/ws; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } } Perhaps there are some other settings that can be changed?

