How To Host A Python Socket Server On Glitch?

Hey! So im new on glitch and im trying to explore its features. And i have a python application that needs to comminucate with a websocket server.

as you can see i got it running, but i have no idea how im going to connect to it on my client (my program). Thank you all for helping.

Glitch doesn’t offer that as a feature. Your project container gets a restricted network where it can only connect out and receive HTTP requests from a reverse proxy.

I’ve seen people use ngrok to tunnel TCP though. That might work for you if you can handle some manual steps each time you start the server.

2 Likes

You’re using python’s sockets standard library which is not a websocket. There’s a couple options for websockets in python, I’ve had success with the websockets library in the past. There’s also python-socketio if you’re looking for compatibility with the Socket.IO client side javascript library.

The library you used in your code is designed for use over a local network, or more commonly for process to process communication within a single machine. It doesn’t do well handling many clients over the public internet. It also seeks to bind to a specific port, something you can’t do from behind Glitch’s proxy.

Oh i didnt know that! thanks for pointing out. I will try websockets library and come back later if i have a question. Thank you!