websockets-rs / websockets-rs/rust-websocket
`ClientBuilder` panics with "Status code must be Switching Protocols"
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.6k
- Forks
- 225
- PR merge metrics
- No merged PRs in 30d
Description
I'm currently attempting to use rust-websocket to connect to btcmarkets' websocket, however when building a rust-websocket client I get
thread 'btcmarkets' panicked at 'called `Result::unwrap()` on an `Err` value: ResponseError("Status code must be Switching Protocols")'
This is is the rust code I have for attempting to connect to the btcmarkets websocket:
// Connect client.
const CONNECTION: &'static str = "https://socket.btcmarkets.net";
let client = ClientBuilder::new(CONNECTION)
.unwrap()
.connect_insecure()?;
I've tried adding "rust-websocket" and "websocket" protocols but the same error occurs. That said I don't really know what I'm doing with the add_protocol method or how protocols are used by websockets (this is my first time programatically connecting to a websocket).
I tried the example node.js code provided by btcmarkets and it seems to work fine - here's that code:
var socket = require('socket.io-client')('https://socket.btcmarkets.net', {secure: true, transports: ['websocket'], upgrade: false});
var instrument = 'BTC';
var currency = 'AUD';
var eventName = 'newTicker';
var channelName = 'Ticker-BTCMarkets-' + instrument + "-" + currency;
socket.on('connect', function(){
console.log('connected');
socket.emit('join', channelName);
});
socket.on(eventName, function(data){
console.log(data);
});
socket.on('disconnect', function(){
console.log('disconnected');
});
If you could offer any advice on the cause of this error and how I might work around it that would be greatly appreciated!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the ClientBuilder::new and connect_insecure calls shown in the report, then trace the WebSocket handshake response handling. Compare the btcmarkets endpoint's expected connection protocol with the library's RFC6455 handshake requirements. Done means reproducing the failure and either supporting the endpoint or documenting the incompatibility and required connection type.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100