[Python] How to set websocket session parmateters using Autobahn in Python

Discussão em 'Python' iniciado por Stack, Julho 12, 2025.

  1. Stack

    Stack Membro Participativo

    I am using the Autobahn library for websocket connection in Python to Node.js server. I have to change header and origin parameters of the connection but its giving me error that

    factory.setSessionParameters(url="wss://xyz.com",origin='54:53:ed:29:23:85',protocols=['ovrc-protocol'],useragent=None,headers={'name':'ravi'})
    TypeError: setSessionParameters() got an unexpected keyword argument 'headers'


    I even tried to save the values in keywords and pass those keywords as arguments to the setSessionfatory method

    url= "wss://xyz.com:1443"
    headers = { 'Sec-WebSocket-Key':'uRovscZjNol/umbTt5uKmw==' }
    origin='50:50:ed:27:21:33'
    protocols=['wxyz-protocol']
    useragent=None

    factory.setProtocolOptions(version=13,utf8validateIncoming=False)
    factory.setSessionParameters(url,origin,protocols,useragent,headers)


    But then it return with error saying method setSessionParameters accepts 5 argument, 6 arguments provided

    Clearly there are only 5 arguments. I was following this link for the method

    It has details for setSessionParameters and its an actual doc but its not working at all.

    If possible please suggest easier way to do websocket connection in Python where I can change websocket parameters like origin and sec-WebSocket-key value etc.

    Continue reading...

Compartilhe esta Página