B4J Question [WebSocket] What is the maximum length of the text message sent?

Discussion in 'B4J Questions' started by Waldemar Lima, Dec 3, 2019 at 7:47 PM.

  1. Waldemar Lima

    Waldemar Lima Active Member Licensed User

    Can i send a file , a image , or a unlimited string words over WebSocket Message Package ?
     
  2. drgottjr

    drgottjr Active Member Licensed User

    you can send binary data or strings. you have to tell the server what you're sending. the spec allows for a very, very large amount of data per frame, but the server on the answering end may have a default max size. if you're running the server, you'd have to check your config file. or find out from the server's administrator what the max is.
     
    Waldemar Lima likes this.
  3. Waldemar Lima

    Waldemar Lima Active Member Licensed User

    how can i set message size of my server ?
     
    Last edited: Dec 4, 2019 at 2:20 AM
  4. drgottjr

    drgottjr Active Member Licensed User

    your server will/should have a configuration file. you need to check the documentation for it. hard to say which server you're running. generally, you edit a line of text in that file to set a maximum payload per frame, stop the server and restart it. you must have edited the configuration file when you first fired up the server, right? either you will add a line (if one is not already there) or you edit the one that is there.
     
    Waldemar Lima likes this.
  5. Erel

    Erel Administrator Staff Member Licensed User

  6. Waldemar Lima

    Waldemar Lima Active Member Licensed User

  7. Erel

    Erel Administrator Staff Member Licensed User

  8. Waldemar Lima

    Waldemar Lima Active Member Licensed User

    using it, i have this error > http://prntscr.com/q68crc


    Code:
    2019-12-04 16:19:00.944:INFO::JavaFX Application Thread: Logging initialized @627ms to org.eclipse.jetty.util.log.StdErrLog
    WebSocket Connected
    Erro = (IllegalStateException) java.lang.IllegalStateException: Interval must be larger than 
    0.
    Erro = (RuntimeException) java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalStateException: Interval must be larger than 
    0.
    websockethandler._ws_connected (java line: 
    116)
    java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalStateException: Interval must be larger than 
    0.
        at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:
    496)
        at anywheresoftware.b4a.keywords.Common.CallSubNew(Common.java:
    434)
        at b4j.example.websockethandler._ws_connected(websockethandler.java:
    116)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
    62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
    43)
        at java.lang.reflect.Method.invoke(Method.java:
    498)
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:
    91)
        at anywheresoftware.b4a.BA$
    3.run(BA.java:247)
        at com.sun.javafx.application.PlatformImpl.lambda$
    null$172(PlatformImpl.java:295)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.javafx.application.PlatformImpl.lambda$runLater$
    173(PlatformImpl.java:294)
        at com.sun.glass.ui.InvokeLaterDispatcher$
    Future.run(InvokeLaterDispatcher.java:95)
        at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at com.sun.glass.ui.win.WinApplication.lambda$
    null$147(WinApplication.java:177)
        at java.lang.Thread.run(
    Thread.java:748)
    Caused by: java.lang.RuntimeException: java.lang.IllegalStateException: Interval must be larger than 
    0.
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:
    120)
        at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:
    487)
        ... 
    15 more
    Caused by: java.lang.IllegalStateException: Interval must be larger than 
    0.
        at anywheresoftware.b4a.objects.Timer.setEnabled(
    Timer.java:76)
        at b4j.example.pushservice2._wsh2_connected(pushservice2.java:
    199)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
    62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
    43)
        at java.lang.reflect.Method.invoke(Method.java:
    498)
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:
    91)
        ... 
    16 more
     
  9. DonManfred

    DonManfred Expert Licensed User

    no you are not.
    Code:
    Sub SetMaxTextMessage(size As Int)
       
    Dim jo As JavaObject = ws
       jo = jo.GetFieldJO(
    "session").RunMethod("getPolicy"Null)
       jo.RunMethod(
    "setMaxTextMessageSize"Array(size))
    End Sub
    I dont see you using this code in your screenshot. Or only partially.
     
    Erel and Waldemar Lima like this.
  10. Waldemar Lima

    Waldemar Lima Active Member Licensed User

Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice