WebSocket API - "NUL" in the response for the rate request

Hi Team,
I am getting "null" in the response message.
It only happened at the initial stage of the WebSocket API communication (only once).
I am requesting the RIC code in batches and I have total 500+ RIC codes and I am calling them in 200 batches.
Could you please help me to figure out what is root cause of the issue.
Let me know if you need more detail here.
Below is the error message (blank space in the below message is having the NUL character):
Exception - byte count[40960]. Value - [[{"ID":9,"Type":"Refresh","Key":{"Service":"ELEKTRON_DD","Name":"CHF="},"State":{"Stream":"Open","Data":"Ok"},"Qos":{"Timeliness":"Realtime","Rate":"JitConflated"},"PermData":"AwEBUmw=","SeqNumber":41582,"Fields":{"DSPLY_NAME":"ARAB BANK MNA","HIGH_1":0.9304,"LOW_1":0.9274,"OPEN_PRC":0.9281,"HST_CLOSE":0.9275,"BID":0.9301,"ASK":0.9302,"BID_HIGH_1":0.9304,"BID_LOW_1":0.9273}},{"ID":71,"Type":"Refresh","Key":{"Service":"ELEKTRON_DD","Name":"AUD2M="},"State":{"Stream":"Open","Data":"Ok"},"Qos":{"Timeliness":"Realtime","Rate":"JitConflated"},"PermData":"AwEBUUHA","SeqNumber":28158,"Fields":{"DSPLY_NAME":"BROKER GFX","HIGH_1":2.54,"LOW_1":2.45,"OPEN_PRC":2.45,"HST_CLOSE":2.47,"BID":2.39,"ASK":2.54,"BID_HIGH_1":2.54,"BID_LOW_1":2.15}},{"ID":77,"Type":"Refresh","Key":{"Service":"ELEKTRON_DD","Name":"AUD1Y="},"State":{"Stream":"Open","Data":"Ok"},"Qos":{"Timeliness":"Realtime","Rate":"JitConflated"},"PermData":"AwEBUUHA","SeqNumber":59502,"Fields":{"DSPLY_NAME":"BROKER GFX","HIGH_1":6.41,"LOW_1":6.20,"OPEN_PRC":4.69,"HST_CLOSE":5.05,"BID":5.15,"ASK":6.65,"BID_HIGH_1":6.41,"BID_LOW_1":3.92}},{"ID":86,"Type":"Refresh","Key":{"Service":"ELEKTRON_DD","Name":"CADTN="},"State":{"Stream":"Open","Data":"Ok"},"Qos":{"Timeliness":"Realtime","Rate":"JitConflated"},"PermData":"AwEBUUHA","SeqNumber":26478,"Fields":{"DSPLY_NAME":"Commerzbank LON","HIGH_1":0.0200,"LOW_1":-0.0040,"OPEN_PRC":-0.0530,"HST_CLOSE":-0.0390,"BID":-0.0 320,"ASK":0.0180,"BID_HIGH_1":0.0200,"BID_LOW_1":-0.1130}},{"ID":139,"Type":"Refresh","Key":{"Service":"ELEKTRON_DD","Name":"JPY2Y="},"State":{"Stream":"Open","Data":"Ok"},"Qos":{"Timeliness":"Realtime","Rate":"JitConflated"},"PermData":"AwEBUkHA","SeqNumber":7166,"Fields":{"DSPLY_NAME":"STANCHART SIN","HIGH_1":-129.70,"LOW_1":-128.37,"OPEN_PRC":-131.25,"HST_CLOSE":-131.27,"BID":-132.53,"ASK":-128.04,"BID_HIGH_1":-129.70,"BID_LOW_1":-140.42}},{"ID":142,"Type":"Refresh","Key":{"Service":"ELEKTRON_DD","Name":"JPY5Y="},"State":{"Stream":"Open","Data":"Ok"},"Qos":{"Timeliness":"Realtime","Rate":"JitConflated"},"PermData":"AwEBUkHA","SeqNumber":2702,"Fields":{"DSPLY_NAME":"STANDCHART NYC","HIGH_1":-672.49,"LOW_1":-678.83,"OPEN_PRC":-686.75,"HST_CLOSE":-717.50,"BID":-693.07,"ASK":-675.20,"BID_HIGH_1":-672.49,"BID_LOW_1":-728.50}},{"ID":131,"Type":"Refresh","Key":{"Service":"ELEKTRON_DD","Name":"JPY1M="},"State":{"Stream":"Open","Data":"Ok"},"Qos":{"Timeliness":"Realtime","Rate":"JitConflated"},"PermData":"AwEBUUHA","SeqNumber":37086,"Fields":{"DSPLY_NAME":"COMMERZBANK FFT","HIGH_1":-3.58,"LOW_1":-3.74,"OPEN_PRC":-4.39,"HST_CLOSE":-3.97,"BID":-3.78,"ASK":-3.50,"BID_HIGH_1":-3.58,"BID_LOW_1":-4.39}},{"ID":136,"Type":"Refresh","Key":{"Service":"ELEKTRON_DD","Name":"JPY6M="},"State":{"Stream":"Open","Data":"Ok"},"Qos":{"Timeliness":"Realtime","Rate":"JitConflated"},"PermData":"AwEBUUHA","SeqNumber":25886,"Fields":{"DSPLY_NAME":"BOA SIN","HIGH_1":-21.21,"LOW_1":-21.11,"OPEN_PRC":-22.95,"HST_CLOSE":-21.87,"BID":-21.42,"ASK":-20.92,"BID_HIGH_1":-21.21,"BID_LOW_1":-23.10}},{"ID":149,"Type":"Refresh","Key":{"Service":"ELEKTRON_DD","Name":"HKDTN="},"State":{"Stream":"Open","Data":"Ok"},"Qos":{"Timeliness":"Realtime","Rate":"JitConflated"},"PermData":"AwEBVFTA","SeqNumber":43758,"Fields":{"DSPLY_NAME":"BOA SIN","HIGH_1":0.50,"LOW_1":-0.27,"OPEN_PRC":-2.70,"HST_CLOSE":-1.20,"BID":-0.45,"ASK":0.05,"BID_HIGH_1":0.50,"BID_LOW_1":-2.80}},{"ID":14,"Type":"Refresh","Key":{"Service":"ELEKTRON_DD","Name":"EUR2M="},"State":{"Stream":"Open","Data":"Ok"},"Qos":{"Timeliness":"Realtime","Rate":"JitConflated"},"PermData":"AwEBUUHA","SeqNumber":17006,"Fields":{"DSPLY_NAME":"SOC GENERAL PAR","HIGH_1":16.12,"LOW_1":15.74,"OPEN_PRC":14.97,"HST_CLOSE":14.51,"BID":15.70,"ASK":16.16,"BID_HIGH_1":16.12,"BID_LOW_1":14.43}},{"ID":41,"Type":"Refresh","Key":{"Service":"ELEKTRON_DD","Name":"GBP1Y="},"State":{"Stream":"Open","Data":"Ok"},"Qos":{"Timeliness":"Realtime","Rate":"JitConflated"},"PermData":"AwEBUUHA","SeqNumber":23294,"Fields":{"DSPLY_NAME":"SOC GENERAL PAR","HIGH_1":17.64,"LOW_1":18.06,"OPEN_PRC":15.82,"HST_CLOSE":16.14,"BID":14.80,"ASK":19.75,"BID_HIGH_1":17.64,"BID_LOW_1":12.44}},{"ID":95,"Type":"Refresh","Key":{"Service":"ELEKTRON_DD","Name":"CAD9M="},"State":{"Stream":"Open","Data":"Ok"},"Qos":{"Timeliness":"Realtime","Rate":"JitConflated"},"PermData":"AwEBUUHA","SeqNumber":56062,"Fields":{"DSPLY_NAME":"NAB SYD","HIGH_1":1.00,"LOW_1":1.65,"OPEN_PRC":-0.30,"HST_CLOSE":-0.65,"BID":-0.10,"ASK":2.30,"BID_HIGH_1":1.00,"BID_LOW_1":-1.65}},{"ID":110,"Type":"Refresh","Key":{"Service":"ELEKTRON_DD","Name":"CHF1M="},"State":{"Stream":"Open","Data":"Ok"},"Qos":{"Timeliness":"Realtime","Rate":"JitConflated"},"PermData":"AwEBUUHA","SeqNumber":36366,"Fields":{"DSPLY_NAME":"BOA SIN","HIGH_1":-7.89,"LOW_1":-8.56,"OPEN_PRC":-8.64,"HST_CLOSE":-8.88,"BID":-8.58,"ASK":-8.18,"BID_HIGH_1":-7.89,"BID_LOW_1":-11.00}},{"ID":115,"Type":"Refresh","Key":{"Service":"ELEKTRON_DD","Name":"CHF6M="},"State":{"Stream":"Open","Data":"Ok"},"Qos":{"Timeliness":"Realtime","Rate":"JitConflated"},"PermData":"AwEBUUHA","SeqNumber":32158,"Fields":{"DSPLY_NAME":"STANCHART SIN","HIGH_1":-47.63,"LOW_1":-47.64,"OPEN_PRC":-49.70,"HST_CLOSE":-48.41,"BID":-50.07,"ASK":-44.64,"BID_HIGH_1":-47.63,"BID_LOW_1":-53.72}},{"ID":158,"Type":"Refresh","Key":{"Service":"ELEKTRON_DD","Name":"HKD9M="},"State":{"Stream":"Open","Data":"Ok"},"Qos":{"Timeliness":"Realtime","Rate":"JitConflated"},"PermData":"AwEBVFTA","SeqNumber":45134,"Fields":{"DSPLY_NAME":"NAB SYD","HIGH_1":6.00,"LOW_1":-0.35,"OPEN_PRC":-4.00,"HST_CLOSE":-1.00,"BID":0.00,"ASK":10.00,"BID_HIGH_1":6.00,"BID_LOW_1":-10.00}},{"ID":17,"Type":"Refresh","Key":{"Service":"ELEKTRON_DD","Name":"EUR5M="},"State":{"Stream":"Open","Data":"Ok"},"Qos":{"Timeliness":"Realtime","Rate":"JitConflated"},"PermData":"AwEBUUHA","SeqNumber":222,"Fields":{"DSPLY_NAME":"NAB SYD","HIGH_1":39.69,"LOW_1":39.61,"OPEN_PRC":39.32,"HST_CLOSE":39.25,"BID":39.31,"ASK":39.71,"BID_HIGH_1":39.69,"BID_LOW_1":37.02}}] ]
EXCEPTION (type = JsonReaderException) : After parsing a value an unexpected character was encountered: 3. Path '[3].Fields.BID', line 1, position 8192.
at Newtonsoft.Json.JsonTextReader.ParsePostValue()
at Newtonsoft.Json.JsonTextReader.ReadInternal()
at Newtonsoft.Json.JsonTextReader.Read()
at Newtonsoft.Json.Linq.JContainer.ReadContentFrom(JsonReader r)
at Newtonsoft.Json.Linq.JContainer.ReadTokenFrom(JsonReader reader)
at Newtonsoft.Json.Linq.JArray.Load(JsonReader reader)
at Newtonsoft.Json.Linq.JArray.Parse(String json)
Thanks
Pradeep B
Best Answer
-
Please try to use result.Result.Count instead of readBuffer.Count when calling the memoryStream.Write method.
Does it help?
0
Answers
-
Could you please share the code that reads data into the byte count[40960]?
From the output, the size of the JSON message is less than 40960. I assume that it could be garbage characters in the count variable.
0 -
Hi @Jirapongse
Yes, agree that there are some garbage characters in the message (The same can we observed in the image attached in the initial message)
I am using Encoding.ASCII.GetBytes(jsonMsg) to get the count.
Thanks
Pradeep B
0 -
Hi Team,
Any comments here?
Thanks
Pradeep B
0 -
Please share the full source code so we can verify it and use it to replicate the issue. Moreover, please provide the version of .NET and the libraries used by the application.
Refer to the sample code, the size of the buffer is 8192.
private static readonly int BUFFER_SIZE = 8192;
Can you replicate the issue with the sample code?
0 -
Sorry but I can provide the source as it has DB dependency and you will not bale to execute it.
My source code is build on top of the sample code provided in the WebSocket API example only and the buffer size if 8192.
I am using below .NET Library:
System.Net.WebSockets - 4.9
Newtonsoft.Json.dll - 6.0.0.0
Note: I am not getting this issue frequently, in 30 min time window I am getting it 2 or 3 time.
I think the problem is when I am getting the update for multiple RIC code in a single message.
I am getting some invalid char in the message which JSON is not able to deserialize.
Error message:
EXCEPTION (type = JsonReaderException) : After parsing a value an unexpected character was encountered: 2. Path '[7].Fields.ASK', line 1, position 8192.
at Newtonsoft.Json.JsonTextReader.ParsePostValue()
at Newtonsoft.Json.JsonTextReader.ReadInternal()
at Newtonsoft.Json.JsonTextReader.Read()
at Newtonsoft.Json.Linq.JContainer.ReadContentFrom(JsonReader r)
at Newtonsoft.Json.Linq.JContainer.ReadTokenFrom(JsonReader reader)
at Newtonsoft.Json.Linq.JArray.Load(JsonReader reader)
at Newtonsoft.Json.Linq.JArray.Parse(String json)
Please help me to resolve the issue.
0 -
It may relate to this code.
if (!result.Result.EndOfMessage)
{
if (memoryStream == null) memoryStream = new MemoryStream(BUFFER_SIZE * 5);
memoryStream.Write(readBuffer.Array, readBuffer.Offset, readBuffer.Count);
readBuffer = new ArraySegment<byte>(new byte[BUFFER_SIZE]);
}40960 = 8192 * 5
I will verify the problem. You may need to add additional logs in this section to verify its behavior.
0 -
Hi @Jirapongse
Thanks for the above detail.
Any suggestion on what king of more logging I can put?
Will be waiting for your response on your finding with the above code line.
Thanks
Pradeep B
0 -
I am still unable to replicate the issue. However, I have tested the JSON string posted in the question and found that the message is invalid. The value of BID fields of CADTN= contains a space.
I am not sure that it is copy/paste problem or the string really contains a space in the BID's value.
I assume that the application has logged this invalid message. Please save the invalid JSON string in the text file and then attach it in the answer.
0 -
Error detail.txt@jirapongse.phuriphanvichai
Yes, it has empty space BID's value.
Here is the log file attached.
If you open the log file in Notepad++, you can clearly see the invalid character.
Let me know if you need more detail.
0 -
Thanks for the above suggestion, I will make this change and test and let you know the outcome.
0 -
This works.
Thanks...
0
Categories
- All Categories
- 3 Polls
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 690 Datastream
- 1.5K DSS
- 629 Eikon COM
- 5.2K Eikon Data APIs
- 11 Electronic Trading
- 1 Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 255 ETA
- 560 WebSocket API
- 39 FX Venues
- 15 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 25 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 281 Open PermID
- 46 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 23 RDMS
- 2K Refinitiv Data Platform
- 724 Refinitiv Data Platform Libraries
- 4 LSEG Due Diligence
- LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 27 DACS Station
- 121 Open DACS
- 1.1K RFA
- 106 UPA
- 194 TREP Infrastructure
- 229 TRKD
- 918 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 95 Workspace SDK
- 11 Element Framework
- 5 Grid
- 19 World-Check Data File
- 1 Yield Book Analytics
- 48 中文论坛