如何解决为什么使用websocketReuters在R中显示错误消息?
我使用的代码与此示例中的https://github.com/Refinitiv/websocket-api/blob/master/Applications/Examples/R/market_price.R 但是,在此行中出现以下错误,有人可以修复吗?
> # Start websocket handshake
> ws_address = paste("ws://",hostname,":",port,"/",sep="")
> cat(paste("Connecting to WebSocket",ws_address,"...\n"))
Connecting to WebSocket ws://127.0.0.1:15000/ ...
> con = websocket(ws_address,port=as.integer(port),subprotocol="tr_json2",version=13)
Error in websocket(ws_address,port = as.integer(port),subprotocol = "tr_json2",:
Connection error
> library(httpuv)
Attaching package: ‘httpuv’
The following object is masked from ‘package:websockets’:
service
> library(websocket)
Attaching package: ‘websocket’
The following object is masked from ‘package:httpuv’:
WebSocket
> s <- startServer("127.0.0.1",15000,+ list(
+ onWSOpen = function(ws) {
+ # The ws object is a WebSocket object
+ cat("Server connection opened.\n")
+
+ ws$onMessage(function(binary,message) {
+ cat("Server received message:",message,"\n")
+ ws$send(message)
+ })
+ ws$onClose(function() {
+ cat("Server connection closed.\n")
+ })
+ }
+ )
+ )
>
> ws <- websocket::WebSocket$new("ws://127.0.0.1:15000/")
> ws$onMessage(function(event) {
+ cat("Client received message:",event$data,"\n")
+ })
>
> # Wait for a moment before running next line
> ws$send("hello world")
Error in wsSend(private$wsObj,msg) : invalid state
Server connection opened.
> con = websocket(ws_address,:
Connection timeout
或者,可能有不同的方法来获得与websocket(ws_address,version=13)
命令相同的结果
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。