如何通过websocket发送消息?

时间:2020-11-06 14:36:42

标签: python r websocket

我想在R中复制Python market_price_authentication.py代码。在python中,一切正常,但是在R中,我无法向服务器发送消息。在下面,您可以看到我认为错误来自哪里的代码。 当我运行websocket 时,功能错误提示"Connection timeout"

 header_entry = list(name="Cookie", value=paste("AuthToken=", auth_token, ";AuthPosition=", position, ";applicationId=", app_id,";", sep=""))
 #header_entry = list(Domain="Login",ID=1, Key=list(Elements=list(ApplicationId=256,AuthenticationToken=auth_token,
 # i changed                                                               Position=paste(position,":S24533",sep = "")),NameType="AuthnToken"))
 
 headers_list = list(header_entry)
 con = websocket(ws_address, port=as.integer(port), subprotocol="tr_json2", headers=headers_list, version=13)

可能是因为此示例中的websocket函数来自旧程序包,并且header_entry是错误的。在python中,我获得了以下标头,我尝试在R中的#号下获取这些标头。您是否认为我使用的是相同的样式格式?

Connecting to WebSocket wss://emea-1.pricing.streaming.edp.thomsonreuters.com:443/WebSocket ...
WebSocket successfully connected!
SENT:
{
  "Domain":"Login",
  "ID":1,
  "Key":{
    "Elements":{
      "ApplicationId":"256",
      "AuthenticationToken":"XXXXX",
      "Position":"172.17.57.17/S24533"
    },
    "NameType":"AuthnToken"
  }
}

我该如何替换websocket函数以尝试将具有正确标头的正确消息发送到服务器?

market_price_authentication文件的代码可在此处https://github.com/Refinitiv/websocket-api/tree/master/Applications/Examples

中找到

0 个答案:

没有答案