ServerSocket / Socket Write limit

Post

Posted
Rating:
#1 (In Topic #1291)
Banned
 Is it common for HTTP sockets to have a limited Write length for data or can it be set/raised?

I have this program feature…..

I have a ServerSocket running and i connect my program to it.  other programs can also connect to it and those connected can share data.

So for example one program will request the scores list from another user.

When requesting client-1 sends a request msg to the webserver that then sends the request to the user (client 2), then their program sends the requested data back to the server to then be sent to client 1.

The problem is this…
When using my local apache server it all works as expected and the data (quite a long string) is sent in one shot.

But, when i upload the webserver to my online server and try to use it from there I am finding my Read event is only getting some of the data, it's truncated and the rest comes through in another Read event !?

Anyone know if there Is there a way to stop that happening?

I tried Socket.Begin, Socket.Send but that didn't help.
Online now: No Back to the top

Post

Posted
Rating:
#2
Regular
vuott is in the usergroup ‘Regular’
 Hello.
How is the “Read …” command line ?

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#3
Banned

vuott said

Hello.
How is the “Read …” command line ?

It was simply this…

Code (gambas)

  1.   sTxt = Read #Soc, Lof(Soc)
  2.  

I have been able to handle it as i know the text should end with a "}" as it's a collection setting string
If it does not end in } then it saves the currently read text to a buffer and appends each next read event to the buffer until it does end with }

like this…

Code (gambas)

  1.  
  2.   Dim sTxt As String
  3.   Dim Soc As Socket = Last
  4.  
  5.   sTxt = Read #Soc, Lof(Soc)
  6.   sTxt = RTrim(FromUrl(sTxt))
  7.   If Not sTxt Then Return
  8.  
  9.   If $sBuff Then  ' if text is in the buffer then append the read text to it.
  10.     sTxt = $sBuff & sTxt
  11.     $sBuff = ""
  12.  
  13.     If sTxt Not Ends "}" Then  ' if text does not end in } it is incomplete so save to buffer and wait for next read.
  14.       $sBuff = sTxt
  15.       Return
  16.     Endif
  17.  
  18. '  At this point sTxt should now be a complete text and not cause the next line to error.
  19. Dim cCol As Collection = Settings.FromString(sTxt)
  20.  
  21.  

Would have been much easier if the Read event got all the text in one shot like it does on my local apache server.
I wondered if there's an apache setting I could use on the web server?  or a header that forces read/write events to not get split.
Online now: No Back to the top

Post

Posted
Rating:
#4
Regular
vuott is in the usergroup ‘Regular’

BruceSteers said

It was simply this…

Code (gambas)

  1.   sTxt = Read #Soc, Lof(Soc)
  2.  
Is this :? idea able to help you, BruceSteers ?

Code (gambas)

  1. Private ht As New HttpClient As "HttpClient1"
  2.  
  3.  
  4. Public Sub .... etc...etc...
  5.  
  6.   ....etc...etc....
  7.  
  8.  
  9.  
  10. Public Sub HttpClient1_Read()  
  11.  
  12.   Dim sBuf As String  
  13.  
  14.   If Lof(ht) Then  
  15.     sBuf = Read #ht, Lof(ht)
  16.     $st &= sBuf
  17.   End If
  18.  
  19.  
  20.  
  21. Public Sub .... etc...etc...
  22.  
  23.   ...etc....
  24.  ...etc....

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Regular
thatbruce is in the usergroup ‘Regular’
Are you using JSON? In any way. Then beware of stuff (sorry, I have stuff that looks simillar)

Online now: No Back to the top

Post

Posted
Rating:
#6
Banned

thatbruce said

Are you using JSON? In any way. Then beware of stuff (sorry, I have stuff that looks simillar)

no just gb.net  ServerSocket.class on the web server and Socket.class on the clients.

Trying normal Socket (steam) Read / Write methods.
sending plain ascii text (basically a gb.settings style file text)

I'm guessing the data being sent in multiple Writes is a server limitation, or a setting i do not know how to adjust.
Online now: No Back to the top

Post

Posted
Rating:
#7
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’
gbWilly leads the usergroup ‘GambOS Contributor’
gbWilly is in the usergroup ‘Blogger’
I use daemons on my server (at work and at home) that run serversocket based daemons as services.
I use them for remote managing the servers. Think remote update, check log files, restart services and the whole lot.
It is all intranet based

I have a few questions about your setup:

It seems it works in the 'intranet' setup or did you test on your localhost (so your own machine -> detail matters)?
What is the length of what you are sending?
What is the code you use for sending?
What port are you sending/receiving?
What server socket properties have you set/not set?

Just a few questions that pop up that might be of influence in understanding and solving the matter.

I've had same daemon producing different results on different servers running exact same os and configuration.
The difference being that one server threw an error that couldn't bind to the port and the other didn't. Both are running daemon v1.0 (giving error on 1 server) and the recently improved daemon v2.0 (on a different port)
Both servers and daemons did accept my connection… :shock:
Still don't know what is causing the error, but it all works on both servers at work. Daemon v 2.0 is running solo at home server.

I do know that detail really matters.

Some suggestions that might change your result/help solve the problem/give you more insight in the matter:
- Wait in code for less than a seconds can help, if you send a lot in sequence.
- Slower systems react different that faster systems, test for this and see how you can tweak, sometimes simplt changing order stuff happens
- A network sniffer having a look at what really goes on on the cable will help (specially since you send ascii you can see every package contentr in details) will give you insight in the matter.

Keep me posted on your findings, happy to think along..

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: No Back to the top

Post

Posted
Rating:
#8
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’
gbWilly leads the usergroup ‘GambOS Contributor’
gbWilly is in the usergroup ‘Blogger’
Ever solved this?

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: No Back to the top

Post

Posted
Rating:
#9
Banned
No , only in the way previously mentioned.
I make sure the text being sent has a known end sequence.

It was a case of the local machine (localhost) working fine and sending all the text all in one shot but the online server sending it in multiple parts.

So the answer was repeatedly reading the input and adding the text to a string until it detects the end sequence.

Sorry i did not reply to your last message. it got by me.  so to answer..

I have a few questions about your setup:

It seems it works in the 'intranet' setup or did you test on your localhost (so your own machine -> detail matters)?
localhost , just apache2

Code

What is the length of what you are sending?
It varies , basically Images converted to Base64 text.

Code

What is the code you use for sending?
Write #hSocket, sData, , String.Len(sData)

Code

What port are you sending/receiving?
8083

What server socket properties have you set/not set?
 $hServer = New ServerSocket As "Sock"
  $hServer.Port = 8083
  $hServer.Type = Net.Internet
  $hServer.Listen
Online now: No Back to the top

Post

Posted
Rating:
#10
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’
gbWilly leads the usergroup ‘GambOS Contributor’
gbWilly is in the usergroup ‘Blogger’
 I was just curious if you ever got closer to the cause.

I experience different behavior on different systems, all running same RemoteDaemon application using Socket server and client for 2-way communication with my manager software on my system.
It all works now, but over time needed some experimenting now and then on sending and receiving end with short wait instructions.

I also needed to start using end markers (actualy start markers) in the send info if a lot of data in sequence got send to my system. or vice versa. Sometimes seemed that the receiving end couldn' t handle the load in some situations. Start markers was part of the solution on the sending side with short waits in between 0.01 if different stuff in fast sequence is being send. I didn't have to do much on the receiving side other than have it recognize the start markers and act accordingly.

Your problems seems a likewise case, but like mine it seems you got it doing what you want it to do.

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: No Back to the top
1 guest and 0 members have just viewed this.