Disconnects can happen for a number of reasons. Follow the list below for things to check:
Ensure your network connection is reliable and fast enough to receive the data you request. We suggest a connection of at least 10MB/s (80Mbps) with a reputable hosting provider.
If you don't respond to websocket pings or send your own, the connection will be disconnected after 1 min. See more about the ping pong requirement.
Delayed notifications can happen for a number of reasons. Follow the list below for things to check:
Check the status of the websocket here. If your messages are more delayed then proceed to the next item in this list.
Ensure your network connection is reliable and fast enough to receive the data you request. We suggest a connection of at least 10MB/s (80Mbps) with a reputable hosting provider.
If you process the websocket messages too slow, they will start to queue up. You will notice this as the message delay will increase leading to a block time further in the past. Consider adding a swap filter to reduce the amount of data you receive.
Please note that currently, if you dont process the messages fast enough and have a delay of more than 60 seconds, the stream will drop events. We will soon introduce an option to prevent dropped events.
Keep in mind that its possible for a tokens USD price to go up whilst its value goes down. Since these tokens are traded with wSOL, the wSOL/USD ratio may increase whilst your token (e.g. POP) in a pool of wSOL/POP may simultaneously decrease.
To calculate the token price in USD, you have a few options:
https://api.coinbase.com/v2/exchange-rates?currency=USD
You can then multiply the quotePrice in the swap (providing it is in wSOL) by the SOL price provided by the coinbase api.
You can listen to the USDC token on Solana EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
in a pair with wSOL. However when taking this route, ensure you listen to a pool with high enough
liquidity otherwise you will get erratic results.