简体   繁体   English

如何在python中使用高速公路设置websocket会话参数

[英]How to set websocket session parmateters using autobahn in python

I am using autobahn library for websocket connection in python to nodejs server. 我正在将autobahn库用于python中的websocket连接到nodejs服务器。 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 我什至尝试将值保存在关键字中,并将这些关键字作为参数传递给setSessionfatory方法

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 但随后返回错误,提示方法setSessionParameters接受5个参数,提供6个参数

clearly there are only 5 arguments . 显然只有5个论点。 i was following this link for the method http://autobahn.ws/python/websocketclient.html it has details for setSessionParameters and its an actual doc but its not working at all. 我正在使用方法http://autobahn.ws/python/websocketclient.html的此链接,它具有setSessionParameters的详细信息及其实际文档,但根本无法使用。

If possible please suggest me easier way to do websocket connection in python where i can change websocket parameters like origin and sec-WebSocket-key value etc. 如果可能的话,请建议我用更简单的方法在python中进行websocket连接,在这里我可以更改websocket参数,例如origin和sec-WebSocket-key值等。

Thanks 谢谢

Sorry it was a silly mistake apt-get installed an old version of autobahn . 抱歉,apt-get安装了旧版本的autobahn是一个愚蠢的错误。 I have installed the binary provided by autobahn site and problem solved :) 我已经安装了高速公路站点提供的二进制文件并解决了问题:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM