I'm trying use R package httr2 to set up a connection for streaming stock prices. My provider uses WebSocket. I have read documentation and searched high and low, but can't get it to work, following the API documentation and httr2 documentation.
When I do:
library(httr2)
library(dplyr)
token <- paste("BEARER", "mytoken")
url <- paste0("http://streaming.saxobank.com/sim/openapi/streamingws/connect?contextId=4UpfnD4ycH&authorization=", token)
req <- request(url)
show_bytes <- function(x) {
cat("Got ", length(x), " bytes\n", sep = "")
TRUE
}
r <- req %>% req_stream(show_bytes)
I get a 400 error.
I suspect that either I'm approacing this the wrong way, or http2 doesn't support WebSocket?