Websocket connection issues

I am trying to set up socketio on my repl (https://StarryFaroffSequel.bennygh.repl.co/)

I am working with python and flask.

The console on my html page is serving me up this error:

I have set up socket as follows on main.py

app = Flask(__name__)
app.secret_key = "secret123"
socketio = SocketIO(app)

and

if __name__ == '__main__':
    socketio.run(app, debug=True)

And on my html page as follows:

 <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/5.1.2/socket.io.js"></script>
    <script type="text/javascript" charset="utf-8">
      var socket = io(https://StarryFaroffSequel.bennygh.repl.co/);
      socket.on('status_change', function(data) {
        console.log('Status changed: ', data);

        // Update the UI to reflect the user's online status
        var usernameElement = document.getElementById(data.username);
        if (usernameElement) {
          usernameElement.innerText = data.username + ' - ' + data.status;
        }
      });
    </script>

Can someone please help me, as I am pulling my hair out and just trying to create a connection!

Thanks

Hey @bennygh!

repl.co links the way you’re using them no longer exist. You’ll need to either use the new (much longer) replit.dev/repl.co development URLs, or deploy. This is probably the source of your error, since some (older) repl.co pages seem to be intermittently loosing their SSL certs/having them expire.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.