For a deeper look into our Elektron API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
44 10 13 14

WebSocket-Sharp - Issue in DiscoverServices() method from the MarketPriceEdpGwServiceDiscoveryExample

Hi Team,

Need your help.

I am building my new application using .NET Framework 3.5 and WebSocket-Sharp.

I am getting this error in the DicoveryServices() method (The referenced code is used from "MarketPriceEdpGwServiceDiscoveryExample").

Note: I didn't faced this issue in the past while working with the same code in .NET Framework 4.5.

treprdp-apiwebsocketsrrto
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hi @pradeep.badoni,

Is there a requirement to use such an old version of .Net? The .Net community has pretty much stopped releases for .Net framework and have been focussing on .Net Core and now how moved to .Net 5 and beyond. The latest, Microsoft supported version of .Net is 4.5.2.

Hi @pradeep.badoni,

Have you considered using the .Net libraries I recommended, i.e. https://developers.refinitiv.com/en/api-catalog/refinitiv-data-platform/refinitiv-data-platform-libraries? These libraries are specifically designed to do all the heavy lifting of interfacing with streaming, as well as, other data services within RDP. With only a few lines of code, you can stream your content and focus on your specific business requirements instead.

Hi @nick.zincone.1

I didn't get chance to look into the .NET Libraries as I was focusing to work with WebSocket API either using inbuilt .NET WebSocket feature or using WebSocket-Sharp.

Do we have any examples of these .NET Library?

Can we use these .NET Library to connect to WebSocket API server?

Hi @pradeep.badoni,

The link I provided lists numerous examples of using the library. In particular, there are examples to retrieve streaming data (https://github.com/Refinitiv-API-Samples/Example.RDPLibrary.DotNet/tree/master/src/2.%20Content/2.2-Pricing) - they connect to the WebSocket server. The library provides default WebSocket implementations but also allows developers to register their own WebSocket implementation (https://github.com/Refinitiv-API-Samples/Example.RDPLibrary.DotNet/tree/master/src/3.%20Delivery/3.0-Core/3.0.03-Core-WebSocket). For example, you can see I'm using the WebSocketSharp to register within the library. Just navigate down into the project.

The libraries support .Net Framework 4.52 and .Net Standard 2.0. With this, application developers can target .Net Framework applications as well as .Net Core and .Net 5 applications - all of the modern implementations.

Upvotes
Accepted
17.4k 82 39 63

Hi @pradeep.badoni,

I was able to replicate the issue with Json 3.5.8. This is the oldest (first release of the package - about 10 years old). I believe what is happening is there is a conflict between this old version of NewtonSoft Json package and the WebRequest interfaces. It appears NewtonSoft came out with a couple of releases very quickly addressing this issue.

To resolve this, you will have to upgrade to NewSoft Json 4.0.2 - it only came out a couple of months later. Did you try a newer version yet?

thanks.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hi @nick.zincone.1

Not yet, I can try with 4.0.2.

What about the 4.5 Framework program? I believe the NewSoft Json version is higher then 3.5.8.

Let me know your thoughts.

Hi @pradeep.badoni,

What do you want to know about the 4.5 Framework? Yes, it uses a new version of the Json package, but simply change the version. That is what I did. I started off with whatever it was - tested and it worked. I then switched to 3.5.8 and it failed. I then tried a few more to figure out which one seemed to help and it was 4.0.2. Just update your example to the latest possible one for your project.

Hi @nick.zincone.1

Thanks for your input here.

I am able to run both .NET Framework 4.5 (inbuild WebSocket in .NET) and .NET 3.5 Framework with open source WebSocketSharp.

Thanks a lot for your help on this ticket.

Appreciated...

I think we we can close this ticket.

Thanks

Pradeep B

Show more comments
Upvotes
44 10 13 14

Hi @nick.zincone.1

We have few client's at .NET Framework 3.5 which we need to support and they don't have any plan to upgrade to the higher version soon.

Let me know if you need more detail here.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
17.4k 82 39 63

Hi @pradeep.badoni,

I would consider making the client aware of the support for .Net framework 3.5. That being said, assuming they need to move forward now, now that it appears you are able to stream using WebSocketSharp, did you try building the "MarketPriceEdpGwServiceDiscoveryExample" example with .Net Framework 3.5? I don't think it is the intention of the development group to support versions of .Net that aren't supported by Microsoft. Let me know what the result is there to confirm.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
44 10 13 14

Hi @nick.zincone.1

I am getting this issue when debugging the "MarketPriceEdpGwServiceDiscoveryExample" example with .Net Framework 3.5 using WebSocketSharp.

The Authentication works fine and getting issue while Discovering the Service.

Is there any way to fix this error?

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hi @pradeep.bad,

I know you are getting this issue when building with .Net Framework 3.5 using WebSocketSharp. The issue could be with .Net Framework 3.5. Because Microsoft is no longer supporting this old framework, we can't rely on Microsoft to fix it if the error may be within their libraries.

Did you try running the native "MarketPriceEdpGwServiceDiscoveryExample", using .Net Framework 3.5 (NOT using WebSocketSharp, but the actual native example which includes the .Net WebSocket implementation).

I just want to be sure this is related to changes in the .Net Framework.

Hi @nick.zincone.1

The "MarketPriceEdpGwServiceDiscoveryExample", using .Net Framework 3.5 can't be run without using WebSocketSharp as the inbuild feature of WebSockets in .NET is only available from .NET Framework 4.5

Hi @pradeep.badoni,

Ok. Based on the code segment you provided, it does work with .Net Framework 4.5 - I tested. However, there may be some nuances (or issues) with .Net Framework 3.5. If there are issues, there may be workarounds or it may be some setting in 3.5 that you need to apply.

What I would suggest at this point is to see if there are any known changes in 3.5 vs 4.5 with HttpWebRequest - I couldn't find anything at first glance. Also, you can try to see if the Real Time team may be able to help. You can submit your question to the Real-Time issues section (https://github.com/Refinitiv/Real-Time-SDK/issues) and make mention you are using their sample but with .Net Framework 3.5.

Show more comments
Upvotes
44 10 13 14

Hi @nick.zincone.1

Other then DiscoverServices() method issue, I am able finally able to run the code in .NET 3.5 and able to fetch the market data.

For now in the test program I have hardcoded the market data streaming server and move forward.

If i can get more help on DiscoverServices() issue that would be much appreciated.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hi @pradeep.badoni,

I will email you separately to get more details.

Hi @nick.zincone.1

I think I found something interesting here.

Looks like in the DiscoverServices() method, we have some dependency with the JSON dll used in the sample example.

Today, I have created a new C# project taking the code provided in the "MarketPriceEdpGwServiceDiscoveryExample" in VS2013 with .NET framework 4.5 and I have used a older version of "Newtonsoft.Json.dll" (the version is 4.0.0.0)

And I can see the same issue with DiscoverServices() method.

When I changed the "Newtonsoft.Json.dll" to the higher version (provided in the sample example it self - the version is 12.0.1.22628) it worked fine without any issue.

Open Questions:

Is there any dependency on the "Newtonsoft.Json.dll" version?

Why DiscoverServices() method is breaking when the "Newtonsoft.Json.dll" version is lower? In this method we are just using HttpWebRequest not more then that.

Do we need to use "Newtonsoft.Json.dll" 12.0.1.22628 version only? My initial thought was we should be good to use any version of "Newtonsoft.Json.dll".

Let me know your thoughts.

Upvotes
44 10 13 14

Hi @nick.zincone.1

Could you please share your thoughts on the above?

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hi @pradeep.badoni,

When you submit a request to discover the endpoint services, it is not using Json at all. BTW, I looked to see if I could replicate what you observed with an older version of json.net, and there is no such version: 4.0.0.0.

1612456913208.png (150.7 KiB)

Hi @nick.zincone.1

This is what I am using in my .NET 4.5 project with inbuild .NET WebSocket feature and in the Visual studio it does say that the Version is 4.0.0.0.

1612457251804.png (17.0 KiB)

Hi @pradeep.badoni,

Can you please provide me the NuGet version. Thanks.

Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.