We understand that every integration with the Stream Chat API is different, especially considering the multitude of use cases and potential server-side and client-side SDK integrations. Here is a quick checklist of common integration issues that we see.
Make sure your app is located in the correct region and your requests are configured to go to this region
The Stream API is hosted on AWS in several locations around the world. When creating an application on the Stream Dashboard, you have the option to select the location that you'd like your app to be hosted in. It is important to select the region that is closest to the majority of your users. It is then important to set the baseURL of the requests in both your client-side and server-side code immediately after instantiating the client. Like so,
const client = new StreamChat(appID, secret);
client.setBaseURL("https://chat-proxy-singapore.stream-io-api.com");
Common issues related to not setting this up correctly are
- Connection timeouts
- High latency
Resources
https://getstream.io/chat/docs/javascript/multi_region/
https://getstream.zendesk.com/hc/en-us/articles/360058133593-Slow-loading-of-channel-lists
Rate Limits
The Stream API implements rate limits in order to protect our API from excessive traffic and to ensure that integrations are correct. We believe that our rate limits are generous, but hitting a rate limit is still possible. Before going live with an application, you should review your current rate limits in your Stream Dashboard and reach out to the Customer Success team with any questions at https://getstream.io/contact/support/
Resources
https://getstream.io/chat/docs/javascript/rate_limits/
https://getstream.io/chat/docs/javascript/rate_limits_table/
WebSocket Connections
Correct WebSocket connection and disconnection logic is integral to a correct client-side integration with the Stream API. Client-side devices rely on WebSocket connections to receive real-time events related to Chat. When >1 WebSocket connections is opened for a user, there can be a multitude of unexpected behavior, not limited to
- Push notification delivery issues
- Buggy Chat behavior
- Missing messages/events
- Unexpected bills
Resources
https://getstream.io/chat/docs/javascript/instantiating_the_client/
https://getstream.io/chat/docs/javascript/init_and_users/#connecting-the-user
Permission/Auth Checks enabled
Enabling Permission and Auth checks is always recommended for any production release of an application with Stream. Without these enabled, API requests will bypass our security and permissions system, and can lead to unexpected behavior and security problems.
Resources
https://getstream.io/chat/docs/javascript/app_settings_auth/
https://getstream.io/chat/docs/javascript/application_settings/#application-settings
Catching Errors
If there is a problem with your API requests, the Stream API is designed to return HTTP codes and error messages that correspond to the exact problem. For example if you try to create a channel with a member who doesn't exist in your application, the API will return the following 400 response.
Error: StreamChat error code 4: GetOrCreateChannel failed with error:
"The following users are specified in channel.members but don't exist: [not-a-user].
Please create the user objects before setting up the channel."
The Stream team strongly recommends integration an error tracking system, such as sentry.io or similar tool. It will give you great insight into any error. For example,
Resources
https://getstream.io/chat/docs/javascript/api_errors_response/
https://docs.sentry.io/platforms/node/
Comments
0 comments
Please sign in to leave a comment.