Just starting out? Need help? Post your questions and find answers here.
Stefan
 
Posts: 55
Joined: Mon Feb 05, 2018 9:44 pm

The data transmission of long strings takes a long time

by Stefan Mon Jan 28, 2019 8:44 am

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?
User avatar
Peter
 
Posts: 577
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1

Re: The data transmission of long strings takes a long time

by Peter Mon Jan 28, 2019 9:23 am

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.
Fred
Site Admin
 
Posts: 1130
Joined: Mon Feb 24, 2014 10:51 am

Re: The data transmission of long strings takes a long time

by Fred Mon Jan 28, 2019 9:25 am

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 ?
the.weavster
 
Posts: 138
Joined: Sat Mar 01, 2014 3:02 pm

Re: The data transmission of long strings takes a long time

by the.weavster Mon Jan 28, 2019 9:57 am

Is the text coming from your server from a script you've created?
If so you could look at using chunked transfer encoding
Stefan
 
Posts: 55
Joined: Mon Feb 05, 2018 9:44 pm

Re: The data transmission of long strings takes a long time

by Stefan Mon Jan 28, 2019 11:28 am

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
User avatar
Peter
 
Posts: 577
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1

Re: The data transmission of long strings takes a long time

by Peter Mon Jan 28, 2019 12:27 pm

Image

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...
Fred
Site Admin
 
Posts: 1130
Joined: Mon Feb 24, 2014 10:51 am

Re: The data transmission of long strings takes a long time

by Fred Mon Jan 28, 2019 1:27 pm

Yes, would be helpful to have a fully working snippet, especially if you add some inline JS :)
Stefan
 
Posts: 55
Joined: Mon Feb 05, 2018 9:44 pm

Re: The data transmission of long strings takes a long time

by Stefan Mon Jan 28, 2019 4:29 pm

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



the.weavster
 
Posts: 138
Joined: Sat Mar 01, 2014 3:02 pm

Re: The data transmission of long strings takes a long time

by the.weavster Tue Jan 29, 2019 8:04 am

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.
Return to Coding Questions

Who is online

Users browsing this forum: No registered users and 5 guests