Python-socketio: can you use this without all the webserver stuff?

Created on 8 Apr 2017  路  22Comments  路  Source: miguelgrinberg/python-socketio

I want to run the socket.io server by itself without a webserver.

question

Most helpful comment

As general advice for success in life, @LoganDark I'm not sure why you'd be replying as if the person you're asking for help is an idiot...

All 22 comments

A Socket.IO server is a web server, it works on the same protocols as a regular web server (HTTP and WebSocket).

You don't need to create regular HTTP routes if you don't want to, but you do need the server component to run the Socket.IO logic.

I just want to do for example connecting to the server and communicating, no webpages or anything

That's fine, all you need is a Socket.IO client, and there are clients for pretty much any language.

you misunderstand my intention

i mean running a SERVER BY ITSELF where absolutely nothing is running except socketio server, no webpages or anything

A server running by itself does nothing. You need clients that connect and communicate with the server. What kind of client are you thinking in using? This has nothing to do with HTML/CSS/JavaScript, I'm asking about Socket.IO client here.

FFS!

I'm going to run a server, and use a client in a STANDALONE SEPARATE APP to connect to it remotely????

What does it take to make you understand?

(no offense)

like a server without the middleware or whatever it's called. throw flask/namespaces out and use the server by itself, how do I do that?

how would I do it? (I know how to set up the client I mean the server).

Can you answer my question, please? What Socket.IO client do you plan on using?

And BTW, what does Flask have to do with this? Where did I talk about Flask? That's not even a dependency of this package.

@miguelgrinberg idk why I said flask, I saw it somewhere related to here.

anyway, what does the client have to do with this? i'm using the official socket.io one,for webpages

The examples use Flask, aiohttp, or sanic to serve the client application to the web browser. You clearly don't need that, so if you use one of those examples to start from, just delete all the stuff that serves HTML and JavaScript to the client.

To initialize this package without having a web framework do it as follows:

sio = socketio.Server()
app = socketio.Middleware(sio)

app is the most ambiguous variable I've ever seen without any imports.

Then go ahead and change it on your application. I won't be mad.

What are you changing though? Does it have to be in some object named app, if so, what do I import? :(

I have no idea what to do here, your code can't be run by itself and I don't know what to add.

You are not really being very clear, I'm having a hard time understanding what the problem is. In the example above, app is a variable. You can call it my_app, or whatever else you want. It's not an import, that's your WSGI application,

WSGI application? Is that a socketio thing? What do I import to get a WSGI application?

Can you give me complete code instead of a snippet, because I have no idea what to do with that snippet you gave me.

WSGI is a Python standard for web applications. The snippet I gave you is how you would modify one of the examples in this repository (in the examples/wsgi directory) to not have a dependency on Flask.

I don't have any examples that don't serve the client files, sorry. I recommend that you start from one of those wsgi examples, then remove what you don't need.

As general advice for success in life, @LoganDark I'm not sure why you'd be replying as if the person you're asking for help is an idiot...

Sorry.

Was this page helpful?
0 / 5 - 0 ratings