sock.lua icon indicating copy to clipboard operation
sock.lua copied to clipboard

Any way to use WSS (secure websockets) with sock.lua?

Open Universezero opened this issue 1 year ago • 1 comments

I'm making a game in Love2D, and have used sock.lua for the networking. This works fine when the game is running on Windows or Android, but as soon as I host the game on my website using love.js, the networking no longer works since the game is served through a HTTPS website, which blocks any non-secure external websocket connections. I tried to get around this by using nginx as a secure websocket endpoint for my server (i.e. nginx acts as a secure websocket proxy, and hands data to and from the non-secure websocket server running sock.lua on the same machine), however this doesn't seem to work as sock.lua won't connect to the WSS nginx endpoint from the client. Is there any way to get around this, or do I need to use a different library for my game client networking? Is there any easy fix where sock.lua can hand all its data to a library that will then communicate with my WSS endpoint (i.e. I don't need to rewrite all my client-side game logic using a new lua library)?

Universezero avatar Dec 22 '24 05:12 Universezero

I can't make any recommendations for that setup specifically as I'm not familiar with it, but sock.lua is based based on the lua-enet library which is a binding around the C enet library, which is a networking based on UDP. I think WebSockets are based on TCP, so I suppose you would need to somehow tunnel that UDP connection over TCP or something like that.

camchenry avatar Jan 02 '25 17:01 camchenry