B4J Question GetVal.Value - Waiting for value

ilan

Expert
Licensed User
Longtime User
hi

i use WebSocket in my b4j web app and i get a lot of "Waiting for value (110 ms)" in the logs and i wonder if i am doing something wrong?

i have a form and i am getting the data from the Textfields via JQueryElement. i could use a form-post request instead. is that the better approach?
or can i still use JQueryElements and get the data via GetVal.Value but avoid too many "Waiting for value (110 ms)" logs?

this is how my logs look like:

Waiting for debugger to connect...
Program started.
Jul 25, 2021 11:24:41 PM com.mchange.v2.log.MLog
INFO: MLog clients using java 1.4+ standard logging.
Jul 25, 2021 11:24:41 PM com.mchange.v2.c3p0.C3P0Registry
INFO: Initializing c3p0-0.9.5.2 [built 08-December-2015 22:06:04 -0800; debug? true; trace: 10]
inline data success
2021-07-25 23:24:42.038:INFO::main: Logging initialized @1094ms to org.eclipse.jetty.util.log.StdErrLog
Jul 25, 2021 11:24:42 PM com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource
INFO: Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 20000, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, contextClassLoaderSource -> caller, dataSourceName -> 2rvxu9ai1pyw5ijp6fi4i|4ac68d3e, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> org.mariadb.jdbc.Driver, extensions -> {}, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, forceSynchronousCheckins -> false, forceUseNamedDriverClass -> false, identityToken -> 2rvxu9ai1pyw5ijp6fi4i|4ac68d3e, idleConnectionTestPeriod -> 600, initialPoolSize -> 3, jdbcUrl -> jdbc:mariadb://10.0.0.26/admanager?useSSL=false&characterEncoding=utf-8, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime ...
2021-07-25 23:24:42.175:INFO:eek:ejs.Server:main: jetty-9.4.z-SNAPSHOT; built: 2018-05-03T15:56:21.710Z; git: daa59876e6f384329b122929e70a80934569428c; jvm 1.8.0_261-b12
2021-07-25 23:24:42.212:INFO:eek:ejs.session:main: DefaultSessionIdManager workerName=node0
2021-07-25 23:24:42.212:INFO:eek:ejs.session:main: No SessionScavenger set, using defaults
2021-07-25 23:24:42.213:INFO:eek:ejs.session:main: node0 Scavenging every 660000ms
2021-07-25 23:24:42.231:INFO:eek:ejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@453da22c{/,file:///C:/Users/%D7%90%D7%99%D7%9C%D7%9F/Desktop/AdPro%20-%20B4J%20Web%20App/Objects/www/,AVAILABLE}
2021-07-25 23:24:42.245:INFO:eek:ejs.AbstractNCSARequestLog:main: Opened C:\Users\׳׳™׳׳\Desktop\AdPro - B4J Web App\Objects\logs\b4j-2021_07_25.request.log
2021-07-25 23:24:42.258:INFO:eek:ejs.AbstractConnector:main: Started ServerConnector@58fdd99{HTTP/1.1,[http/1.1]}{0.0.0.0:80}
2021-07-25 23:24:42.264:INFO:eek:ejus.SslContextFactory:main: x509=X509@5d20e46(jetty,h=[],w=[]) for SslContextFactory@709ba3fb[provider=null,keyStore=file:///C:/Users/%D7%90%D7%99%D7%9C%D7%9F/Desktop/AdPro%20-%20B4J%20Web%20App/Objects/keystore,trustStore=null]
2021-07-25 23:24:42.587:INFO:eek:ejs.AbstractConnector:main: Started ServerConnector@5c5eefef{SSL,[ssl, http/1.1]}{0.0.0.0:443}
2021-07-25 23:24:42.587:INFO:eek:ejs.Server:main: Started @1644ms
Emulated network latency: 100ms
is connected to sql: true
Waiting for value (100 ms)
Waiting for value (100 ms)
Waiting for value (101 ms)
Waiting for value (100 ms)
Waiting for value (100 ms)
Waiting for value (100 ms)
Waiting for value (100 ms)
Waiting for value (101 ms)
Waiting for value (101 ms)
Waiting for value (100 ms)
Waiting for value (101 ms)
called
Waiting for value (101 ms)
Waiting for value (100 ms)
Waiting for value (101 ms)
Waiting for value (101 ms)
Waiting for value (100 ms)
Waiting for value (100 ms)
Waiting for value (101 ms)
Waiting for value (100 ms)
called
Waiting for value (100 ms)
Waiting for value (101 ms)
Waiting for value (101 ms)
Waiting for value (100 ms)
Waiting for value (100 ms)
Waiting for value (100 ms)
Waiting for value (101 ms)
Waiting for value (101 ms)
called
Waiting for value (101 ms)
Waiting for value (100 ms)
Waiting for value (100 ms)
Waiting for value (100 ms)
Waiting for value (101 ms)
Waiting for value (101 ms)
Waiting for value (100 ms)
Waiting for value (100 ms)
called
 

ilan

Expert
Licensed User
Longtime User
actually, this is the jqueryElement click event:

B4X:
Sub sigupBtn_Click (Params As Map)
    Dim userN As String = su_user.GetVal.Value
    Dim userP As String = su_pass.GetVal.Value
    Dim userE As String = su_email.GetVal.Value

    '.....
End Sub

i saw that also in your guess my number _ws example there is a delay when you call .GetVal.Value like something is refreshed in the background.
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
This code is exactly how you shouldn't get the values.

See the network latency section: https://www.b4x.com/android/forum/threads/webapp-hello-world-web-app.39808/#content

ok, I had a look at the thread. did not understand everything but will read it again.

anyway, i assumed that this is the way to do it since it is in the guessmynumber_ws example:

1627280498100.png


but after changing to this:

B4X:
    Dim ft1 As Future = su_user.GetVal
    Dim ft2 As Future = su_pass.GetVal
    Dim ft3 As Future = su_email.GetVal
    Dim ft4 As Future = su_fname.GetVal
    Dim ft5 As Future = su_lname.GetVal
    
    Dim userN As String = ft1.Value
    Dim userP As String = ft2.Value
    Dim userE As String = ft3.Value
    Dim firstN As String = ft4.Value
    Dim lastN As String = ft5.Value   
    
    Log(userN)
    Log(userP)
    Log(userE)
    Log(firstN)
    Log(lastN)

i get only 1 time Waiting for value (114 ms) what makes it much much faster now. i don't understand why but if it works i won't ask to many questions :)
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
i don't understand why but if it works i won't ask to many questions :)

ok understand now 🙏

The correct design is quite simple. When the event starts you need to get all the future values that later are needed.
Only then you should call Future.Value. This allows you to get all the values in a single round trip (Server -> Client -> Server).
 
Upvote 0
Top