-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set datachannel.binaryType = "arraybuffer" in connect() in WebRtcModule #27
Conversation
@minwidth0px Hi, thanks for the PR. Ideally, I'd like to keep the
I think it would be good to understand why the binaryType needs to be configured as part of the WebRtc module before continuing with the PR. As far as I can tell, the only functional difference setting the binaryType in the WebRTC module means the binaryType is configured "before" the channel Also, I think this functionality could be achieved by refactoring the WebRtc /** Connects to a remote peer */
public async connect(remoteAddress: string, port: number): Promise<[WebRtcPeer, RTCDataChannel]> {
const peer = await this.#resolvePeer(await this.#resolveAddress(remoteAddress))
const datachannel = peer.connection.createDataChannel(port.toString(), { ordered: true, maxRetransmits: 16 })
return [peer, datachannel] // returned immediately to caller (Net module) to configure
// the binaryType on same JS tick.
} Will do some digging |
Ok. I'll close this for now as its trivial to open a new one (1 line change).
It's worth noting that setting
So it definitely is strange as you say. The way you are describing it with the WebRTC module setting it on the same tick as opening the channel, it would sound like setting it there should always be more reliable, but that did not appear to be the case. As an aside, how can I run the tests to see if this PR makes more requests succeeded? I'd like to see if this has an effect that can be observed outside of my specific setup, which as I said I don't really understand myself why it is needed there. (Although I will take another look at that again and see if I can simplify it to use a regular RemoteNetworkHub so that it is easier to reason about.) (Also, feel free to supersede this PR if you find a cleaner solution.) |
@sinclairzx81 ok... I did end up doing some more testing to repo this issue, and I found that I actually just didn't run npm update on the test project I was working on. (I only ran it on my other project.) Sorry about that. |
@minwidth0px Hiya,
Yeah, it wouldn't surprise me if setting the binaryType on the same tick as the data channel create has some effect, but really need to test and assert this to be true, so better to defer for now and investigate.
If you grab the latest in the master branch, I've just added new infrastructure to let you run the tests in the browser using a npm script command. $ npm run test:serve # visit: http://localhost:5000 - runs the full test suite
# http://localhost:5000?filter=http:listener - only run the http listener tests If you visit Cheers |
@sinclairzx81 I realized that this was just a mistake on my part and setting datachannel.binaryType = "arraybuffer" in connect() in WebRtcModule in never necessary. I just didn't upgrade the npm package in my second project where I was running this code and I didn't realize. So I just made a stupid mistake here. That's what I meant by #27 (comment) |
See #24 (comment). Edit: nevermind, I didn't run npm update on my second project.