Skip to content
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

Sending rapid commands hang #34

Closed
cwbutler opened this issue Jan 12, 2017 · 3 comments
Closed

Sending rapid commands hang #34

cwbutler opened this issue Jan 12, 2017 · 3 comments

Comments

@cwbutler
Copy link

This library seems to hang when sending rapid values to a tcp server.

I'm sending various buffer arrays and awaiting on response from a tcp server. Everything works fine... but then the client.write method hangs and never resolves the callback. From the documentation it seems that the data never finished sending from the client to the server. I'm not sure how to check to see if the data is still being sent or how to resend.

All I know is client.write seems to hang after rapidly sending values... once I destroy connection and reconnect... it resolves the issue.

I can use regular 'net' module in node just fine.

@aprock
Copy link
Collaborator

aprock commented Jan 12, 2017

do not use this library for performance heavy operations. you might try out react-native-fetch-blob. They avoid the issues below by keeping everything native.

As a react-native native module there are several performance bottlenecks involved in marshaling data quickly across the native/javascript boundary.

  1. react-native doesn't support sending data buffers across the bridge. All data is encoded into Base64 strings and then decoded. more info: RN Issue 1424
  2. all data is piped through a global shared device event queue. (RCTDeviceEventEmitter)

It's possible that moving to RCTEventEmitter could improve your situation, as it is likely that events are getting dropped by RN.

@aprock
Copy link
Collaborator

aprock commented Jan 12, 2017

update: RCTEventEmitter is simply a managing wrapper on top of RCTDeviceEventEmitter, so it's doubtful if it will improve your situation.

@cwbutler
Copy link
Author

You're correct. I ended up writing a NativeModule to make a class around the CocoaAsyncSocket library.

Thanks for the knowledge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants