[iOS] [Fixed] - Fixed code and reason arguments ignored on iOS when listening to WebSocket.onclose#26052
[iOS] [Fixed] - Fixed code and reason arguments ignored on iOS when listening to WebSocket.onclose#26052diegolmello wants to merge 1 commit intofacebook:mainfrom
Conversation
|
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed. If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
|
I tried patching the code from @diegolmello to my project, but it return with So I wrote more lines and it works, but I'm not good at objective-c. Can someone check if I'm doing right? diff --git a/node_modules/react-native/Libraries/WebSocket/RCTSRWebSocket.m b/node_modules/react-native/Libraries/WebSocket/RCTSRWebSocket.m
index 8ce6edc..01a5948 100644
--- a/node_modules/react-native/Libraries/WebSocket/RCTSRWebSocket.m
+++ b/node_modules/react-native/Libraries/WebSocket/RCTSRWebSocket.m
@@ -594,6 +594,7 @@ - (void)closeWithCode:(NSInteger)code reason:(NSString *)reason
}
}
+ [self.delegate webSocket:self didCloseWithCode:code reason:reason wasClean:YES];
[self _sendFrameWithOpcode:RCTSROpCodeConnectionClose data:payload];
});
}
@@ -764,7 +765,9 @@ - (void)handleCloseWithData:(NSData *)data
[self assertOnWorkQueue];
- if (self.readyState == RCTSR_OPEN) {
+ if (_closeCode) {
+ [self closeWithCode:_closeCode reason:_closeReason];
+ } else if (self.readyState == RCTSR_OPEN) {
[self closeWithCode:1000 reason:nil];
}
dispatch_async(_workQueue, ^{ |
|
This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
|
This PR was closed because it has been stalled for 7 days with no activity. |
Summary
Websocket ignores
codeandreasonfromoncloselistener.Some work was done in #24950 to send them to
close, butonclosealways returns1001andStream end encountered:https://github.com/facebook/react-native/blob/master/Libraries/WebSocket/RCTSRWebSocket.m#L1391
This PR calls
didCloseWithCodeat the end ofcloseWithCodeandWebsocket.onclosenow works.Changelog
[iOS] [Fixed] - Fixed
codeandreasonarguments ignored on iOS when listening toWebSocket.oncloseTest Plan
Run integration tests.