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?
The data transmission of long strings takes a long time
Re: The data transmission of long strings takes a long time
As always: no one can make a statement about this without seeing a short, fully functional code that demonstrates this behavior.Stefan wrote:Is this a bug?
Re: The data transmission of long strings takes a long time
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 ?
-
- Posts: 220
- Joined: Sat Mar 01, 2014 3:02 pm
Re: The data transmission of long strings takes a long time
Is the text coming from your server from a script you've created?
If so you could look at using chunked transfer encoding
If so you could look at using chunked transfer encoding
Re: The data transmission of long strings takes a long time
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
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
It seems that you are not really interested in someone helping you...Peter wrote:[...] without seeing a short, fully functional code that demonstrates this behavior.
Re: The data transmission of long strings takes a long time
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
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
-
- Posts: 220
- Joined: Sat Mar 01, 2014 3:02 pm
Re: The data transmission of long strings takes a long time
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.
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
Has anyone found a solution or recognized what the problem can be?