Skip to content

Socket.io

Spout for socket.io

Bases: Spout

__init__(output, state, **kwargs)

Initialize the SocketIo class.

Parameters:

Name Type Description Default
output StreamingOutput

An instance of the StreamingOutput class for saving the data.

required
state State

An instance of the State class for maintaining the state.

required
**kwargs

Additional keyword arguments.

{}

Using geniusrise to invoke via command line

genius SocketIo rise \
    streaming \
        --output_kafka_topic socketio_test \
        --output_kafka_cluster_connection_string localhost:9094 \
    none \
    listen \
        --args url=http://localhost:3000 namespace=/chat

Using geniusrise to invoke via YAML file

version: "1"
spouts:
    my_socketio_spout:
        name: "SocketIo"
        method: "listen"
        args:
            url: "http://localhost:3000"
            namespace: "/chat"
        output:
            type: "streaming"
            args:
                output_topic: "socketio_test"
                kafka_servers: "localhost:9094"

listen(url, namespace=None, event='message', auth=None)

📖 Start listening for data from the Socket.io server.

Parameters:

Name Type Description Default
url str

The Socket.io server URL.

required
namespace Optional[str]

The Socket.io namespace. Defaults to None.

None
event str

The Socket.io event to listen to. Defaults to "message".

'message'
auth Optional[dict]

Authentication dictionary. Defaults to None.

None

Raises:

Type Description
Exception

If unable to connect to the Socket.io server.