WebSocket Params.
FubonNeo API SDK leverages WebSocket to connect with Fubon servers, the standard ping/pong control frame mechanism is adopted and implemented. By default, a ping frame would be sent to the server every 30 seconds, and if pong response is not received for two cconsecutive attempts, the connection quality is judged to be weak and the connection would be dropped.
To accomodate different usage scenarios, since version 2.2.1
, users can set this part of the parameters by themselves. When establishing a connection, you can specify the relevant parameters. For example, if you want to have a ping frame sent every 300 seconds, and drop the connection if three consecutive attempts failed, the corresponding method call would be:
sdk = FubonSDK(300, 3)
The first parameter is the during between two ping attempts (in seconds), and the second parameter is the maximum tolerable number of consecutive fail attempts.
It is common to encounter congestion of Internet from time to time, we recommend that the parameter setting should be less strict than the default value (30,2) to prevent over-sensitivity.
To connect with the simulation mode, use the following method call (for versions >= 2.2.1
):
sdk = FubonSDK(30, 3, "wss://neoapitest.fbs.com.tw/TASP/XCPXWS")
Note. The values for the first two arguments in the example are only for the demonstration purpose. They can be freely adjusted if needed.