Page 1 of 1
The data transmission of long strings takes a long time
Posted: Mon Jan 28, 2019 8:44 am
by Stefan
My server sends a string with 720000 characters to my spider client.
Firefox takes a long time to receive the string, more than 30 seconds, and displays the message: "The website slows down your browser, what should be done?"
My test environment is on a machine (server and client), so I think the transfer should be really fast.
Is this a bug?
Re: The data transmission of long strings takes a long time
Posted: Mon Jan 28, 2019 9:23 am
by Peter
Stefan wrote:Is this a bug?
As always: no one can make a statement about this without seeing a short, fully functional code that demonstrates this behavior.
Re: The data transmission of long strings takes a long time
Posted: Mon Jan 28, 2019 9:25 am
by Fred
That seems to be very slow.. I don't think it's a bug SB side tbh, could you try to do a small snippet ?
Re: The data transmission of long strings takes a long time
Posted: Mon Jan 28, 2019 9:57 am
by the.weavster
Is the text coming from your server from a script you've created?
If so you could look at using
chunked transfer encoding
Re: The data transmission of long strings takes a long time
Posted: Mon Jan 28, 2019 11:28 am
by Stefan
Procedure onMessage(evt)
Protected MessageFromWs.s
! v_messagefromws = v_evt.data;
;It takes about 30 seconds until the whole string (MessageFromWs) has arrived
;This procedure processes messages (strings)
checkMessage(MessageFromWs)
EndProcedure
Re: The data transmission of long strings takes a long time
Posted: Mon Jan 28, 2019 12:27 pm
by Peter
Peter wrote:[...] without seeing a short, fully functional code that demonstrates this behavior.
It seems that you are not really interested in someone helping you...
Re: The data transmission of long strings takes a long time
Posted: Mon Jan 28, 2019 1:27 pm
by Fred
Yes, would be helpful to have a fully working snippet, especially if you add some inline JS
Re: The data transmission of long strings takes a long time
Posted: Mon Jan 28, 2019 4:29 pm
by Stefan
Next try:
Code: Select all
EnableExplicit
Declare initWebSocket(wsuri.s)
Declare checkMessage(aString.s)
Declare onOpen(evt)
Declare onError(evt)
Declare onMessage(evt)
Declare onClose(evt)
Declare doSend(aString.s)
Declare sende(aStr.s)
Structure Chat_Message
Type.s
Author.s
Message.s
Timestamp.q
EndStructure
Structure Chat_Username_Change
Type.s
Username.s
Passwort.s
EndStructure
Structure Chat_Userlist
Type.s
List Username.s()
EndStructure
Global starttime,endtime
initWebSocket("ws://doko-lounge.selfhost.eu:41401")
Procedure onClose(evt)
Debug "onClose"
EndProcedure
Procedure onMessage(evt)
Protected MessageFromWs.s
! v_messagefromws = v_evt.data;
checkMessage(MessageFromWs)
EndProcedure
Procedure onError(evt)
Debug "onError()"
EndProcedure
Procedure initWebSocket(wsuri.s)
! websocket = new WebSocket(v_wsuri);
! websocket.onopen = function(evt) { f_onopen(evt) };
! websocket.onclose = function(evt) { f_onclose(evt) };
! websocket.onmessage = function(evt) { f_onmessage(evt) };
! websocket.onerror = function(evt) { f_onerror(evt) };
EndProcedure
Procedure doSend(message.s)
! websocket.send(v_message);
EndProcedure
Procedure onOpen(evt)
Debug "onOpen()"
EndProcedure
Procedure sende(aStr.s)
Protected M.Chat_Message
Protected JSONID.i
Protected mess.s
M\Author = "Noname"
M\Message = astr
M\Timestamp = Date()
M\Type = "Message"
JSONID = CreateJSON(#PB_Any)
If JSONID <> 0
InsertJSONStructure(JSONValue(JSONID), @M, Chat_Message)
doSend( ComposeJSON(JSONID))
FreeJSON(JSONID)
EndIf
EndProcedure
Procedure checkMessage(aString.s)
Protected.s s,ls
Protected l
Debug aString
If FindString(aString,"<<verbunden>>")>0
l=150000 ;Here you can change (test) the counts of characters
ls=Str(l)
s="<<spiderbasictest>>"+ls+"<</spiderbasictest>>"
sende(s)
Debug "sending: "+ s
EndIf
If FindString(aString,"Start receiving")>0
starttime=ElapsedMilliseconds()
EndIf
If FindString(aString,"End receiving")>0
endtime=ElapsedMilliseconds()-starttime
Debug "Loadingtime: "+Str(endtime)+" ms"
EndIf
EndProcedure
Re: The data transmission of long strings takes a long time
Posted: Tue Jan 29, 2019 8:04 am
by the.weavster
Ah, WebSockets...
What do you have server side? I'm wondering if the server is sending the
correct header to let FireFox know of the length of the data.
Re: The data transmission of long strings takes a long time
Posted: Thu Feb 28, 2019 8:55 pm
by Stefan
Has anyone found a solution or recognized what the problem can be?