6 Replies - 257 Views - Last Post: 18 October 2017 - 01:24 PM Rate Topic: -----

#1 sergiobotta  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 18-October 17

Multiple concurrent connections websocket

Posted 18 October 2017 - 08:36 AM

I need to send data to a different server via webscoket. I have a lot of records to send and the other server can only receive one at a time, so I need to establish a connection each time. I use something like this.

For .... 
  Dim wsDGSA As WebSocket4Net.WebSocket
  wsDGSA = New WebSocket4Net.WebSocket(URL_WSS)
  AddHandler wsDGSA.Opened, AddressOf Me.wsDGSA_Opened
  AddHandler wsDGSA.Error, AddressOf Me.wsDGSA_Error
  AddHandler wsDGSA.Closed, AddressOf Me.wsDGSA_Closed
  AddHandler wsDGSA.MessageReceived, AddressOf Me.wsDGSA_MensajeRecibido
  wsDGSA.Open()
Next



Which is the right form to call the ws connection and not receive this error: "An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full"

Thanks!

Is This A Good Question/Topic? 0
  • +

Replies To: Multiple concurrent connections websocket

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 13493
  • View blog
  • Posts: 53,899
  • Joined: 12-June 08

Re: Multiple concurrent connections websocket

Posted 18 October 2017 - 08:37 AM

Do you control this other server?
Was This Post Helpful? 0
  • +
  • -

#3 sergiobotta  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 18-October 17

Re: Multiple concurrent connections websocket

Posted 18 October 2017 - 08:40 AM

View Postmodi123_1, on 18 October 2017 - 08:37 AM, said:

Do you control this other server?


No I donīt. I only know that I have to send one record each time.
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 13493
  • View blog
  • Posts: 53,899
  • Joined: 12-June 08

Re: Multiple concurrent connections websocket

Posted 18 October 2017 - 08:51 AM

Okay.. then I would advocate _NOT_ flooding their connection/server/etc by blasting them with a whole mess of connections. Some may construe that as being a bad thing.
Was This Post Helpful? 0
  • +
  • -

#5 IronRazer  Icon User is offline

  • Custom Control Freak
  • member icon

Reputation: 1447
  • View blog
  • Posts: 3,682
  • Joined: 01-February 13

Re: Multiple concurrent connections websocket

Posted 18 October 2017 - 10:01 AM

It looks as though the WebSocket4Net has a Closed and MessageRecieved event. Perhaps instead of creating and opening all of the WebSockets in a For Next loop, you should be creating just one in a Sub and opening it. After it receives a message, then close it, dispose it, and then call the sub again to create the next.

I see that the WebSocket class implements IDisposable. So, without knowing all the details of how all your code is set up, we don`t know if you are ever actually Closing and Disposing each the New instances of the WebSocket classes. If you are not closing and disposing them somewhere in your code, then be aware that you should be.
Was This Post Helpful? 1
  • +
  • -

#6 sergiobotta  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 18-October 17

Re: Multiple concurrent connections websocket

Posted 18 October 2017 - 01:05 PM

I am trying your suggestion:

Dim wsDGSA As WebSocket4Net.WebSocket
wsDGSA = New WebSocket4Net.WebSocket(URL_WSS)
AddHandler wsDGSA.Opened, AddressOf Me.wsDGSA_Opened
AddHandler wsDGSA.Error, AddressOf Me.wsDGSA_Error
AddHandler wsDGSA.Closed, AddressOf Me.wsDGSA_Closed
AddHandler wsDGSA.MessageReceived, AddressOf Me.wsDGSA_MensajeRecibido
wsDGSA.Open()
For Each r In nl
   ...
   wsDGSA.Send("...")
Next
wsDGSA.Close()
wsDGSA.Dispose()





It seems to work!!!
Tomorrow I tell you.
Thanks
Was This Post Helpful? 0
  • +
  • -

#7 IronRazer  Icon User is offline

  • Custom Control Freak
  • member icon

Reputation: 1447
  • View blog
  • Posts: 3,682
  • Joined: 01-February 13

Re: Multiple concurrent connections websocket

Posted 18 October 2017 - 01:24 PM

Good Luck. 8)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1