2017R3 WebApp multiple KeyPressed events

I have a web app which puts up some pictures, asks users to answer a few questions, and saves the data. Pretty simple. It’s been working great for a few years. Recently, it started failing again. The failure mode is interesting: some items on the web page will load, but some will not - for example, the Radio button set used for the survey question loads, but the image does not. Safari/mac is fine. On Windows 10, IE11 works fine, but Chrome and Edge don’t work. All of this is running over HTTPS.

What’s changed between the non-working and working situations?

  • I updated Xojo from 2014R2 to 2017R3
  • IE11 has probably not updated, but surely Chrome and Edge have.

An additional issue is that my server is sitting behind a dual-WAN router: when contacting the server, connections from the client to the server come in on a given IP address (a.b.c.D) but connections originating from the server to the client might be going out via a different IP address (a.b.c.E).

So it’s complicated: firewall rules on either the client or the server end could be impacting this.

My theory: I know that Xojo web apps use a lot of AJAX-like connections (using XMLHttprequest ??) where the server pings the browser, or the browser pings the server). I’m wondering if something has changed, either in Xojo 2017R3 or in the Chrome or Edge browsers? I seem to remember reading that Xojo web was using newer methods for this.

Any ideas appreciated.

More info. I took a look at the logs for both versions, and I’m seeing something strange.

On the old version (2017R2.1) when multiple users log in at once, it looks normal:

2017R2.1, 32 bit macOS standalone SSL web app:

[2016-09-15 09:16:41] domen003 login session C11E72A592207336002123B92CCA6608023D1B75
[2016-09-15 09:16:41] dehai001 login session 4C47D2B2FBB21D10713DB16A083247A752678035
[2016-09-15 09:16:44] grave029 selected assignment Exercise02-Survey
[2016-09-15 09:16:51] grave029 began survey
[2016-09-15 09:16:54] dehai001 selected assignment Exercise02
[2016-09-15 09:16:56]  session  6EA3F80E72020266263767E3035371A2AFC576E5 opened from x.x.x.x browser: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36
[2016-09-15 09:16:56]  session  7A76CA47C4334D944ACB80A77F289F9FD8FA376B opened from x.x.x.x browser: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36
[2016-09-15 09:16:58] bluin001 login session 8D101E07CA4ACA12DCA4F8A90D1CB195181A9C47
[2016-09-15 09:17:09] morse012 login session 6EA3F80E72020266263767E3035371A2AFC576E5

However in the newer version, I’m seeing these weird multiple login messages, like this:
2017R3, 64 bit macOS standalone SSL web app:

[2018-02-08 17:05:02] alice004 login session B2D8F3FFEF1192D7541559E4775A0227835899D0
[2018-02-08 17:05:02] baker028 login session 293DA5867D8994284EF7A65144EAE7FEB802440A
[2018-02-08 17:05:03] baker028 login session 293DA5867D8994284EF7A65144EAE7FEB802440A
[2018-02-08 17:05:03] baker028 login session 293DA5867D8994284EF7A65144EAE7FEB802440A
[2018-02-08 17:05:04] alice004 login session B2D8F3FFEF1192D7541559E4775A0227835899D0
[2018-02-08 17:05:04] baker028 login session 293DA5867D8994284EF7A65144EAE7FEB802440A
[2018-02-08 17:05:05] baker028 login session 293DA5867D8994284EF7A65144EAE7FEB802440A
[2018-02-08 17:05:05] baker028 login session 293DA5867D8994284EF7A65144EAE7FEB802440A
[2018-02-08 17:05:05] baker028 login session 293DA5867D8994284EF7A65144EAE7FEB802440A

Zooming in, I searched the Output.log file for the session ID for one user (baker028). Even though I show 7 login attempts across a 3 second time period, from 17:05:02 through 17:05:05, the log doesn’t show anything that matches up:

x.x.x.x - - [08/Feb/2018:17:04:52 -0800] "POST /293DA5867D8994284EF7A65144EAE7FEB802440A/comm/event/GUibQ71t.Action HTTP/1.1" 200 179 "-" "keep-alive"
x.x.x.x - - [08/Feb/2018:17:04:55 -0800] "POST /293DA5867D8994284EF7A65144EAE7FEB802440A/comm/event/phViGabD.KeyPressed HTTP/1.1" 200 2 "-" "keep-alive"
x.x.x.x - - [08/Feb/2018:17:04:56 -0800] "POST /293DA5867D8994284EF7A65144EAE7FEB802440A/comm/event/phViGabD.KeyPressed HTTP/1.1" 200 2 "-" "keep-alive"
x.x.x.x - - [08/Feb/2018:17:04:56 -0800] "POST /293DA5867D8994284EF7A65144EAE7FEB802440A/comm/event/phViGabD.KeyPressed HTTP/1.1" 200 2 "-" "keep-alive"
x.x.x.x - - [08/Feb/2018:17:04:56 -0800] "POST /293DA5867D8994284EF7A65144EAE7FEB802440A/comm/event/phViGabD.KeyPressed HTTP/1.1" 200 2 "-" "keep-alive"
x.x.x.x - - [08/Feb/2018:17:04:58 -0800] "POST /293DA5867D8994284EF7A65144EAE7FEB802440A/comm/event/phViGabD.KeyPressed HTTP/1.1" 200 2 "-" "keep-alive"
x.x.x.x - - [08/Feb/2018:17:04:58 -0800] "POST /293DA5867D8994284EF7A65144EAE7FEB802440A/comm/event/phViGabD.KeyPressed HTTP/1.1" 200 2 "-" "keep-alive"
x.x.x.x - - [08/Feb/2018:17:04:58 -0800] "POST /293DA5867D8994284EF7A65144EAE7FEB802440A/comm/event/phViGabD.KeyPressed HTTP/1.1" 200 2 "-" "keep-alive"
x.x.x.x - - [08/Feb/2018:17:04:58 -0800] "POST /293DA5867D8994284EF7A65144EAE7FEB802440A/comm/event/phViGabD.KeyPressed HTTP/1.1" 200 2 "-" "keep-alive"
x.x.x.x - - [08/Feb/2018:17:05:02 -0800] "POST /293DA5867D8994284EF7A65144EAE7FEB802440A/comm/event/phViGabD.TextChanged HTTP/1.1" 200 2 "-" "keep-alive"
x.x.x.x - - [08/Feb/2018:17:05:02 -0800] "POST /293DA5867D8994284EF7A65144EAE7FEB802440A/comm/event/phViGabD.KeyPressed HTTP/1.1" 200 7718 "-" "keep-alive"
x.x.x.x - - [08/Feb/2018:17:05:03 -0800] "POST /293DA5867D8994284EF7A65144EAE7FEB802440A/comm/event/phViGabD.KeyPressed HTTP/1.1" 200 516 "-" "keep-alive"
x.x.x.x - - [08/Feb/2018:17:05:03 -0800] "POST /293DA5867D8994284EF7A65144EAE7FEB802440A/comm/event/phViGabD.KeyPressed HTTP/1.1" 200 516 "-" "keep-alive"
x.x.x.x - - [08/Feb/2018:17:05:04 -0800] "POST /293DA5867D8994284EF7A65144EAE7FEB802440A/comm/event/phViGabD.KeyPressed HTTP/1.1" 200 516 "-" "keep-alive"
x.x.x.x - - [08/Feb/2018:17:05:05 -0800] "POST /293DA5867D8994284EF7A65144EAE7FEB802440A/comm/event/phViGabD.KeyPressed HTTP/1.1" 200 516 "-" "keep-alive"
x.x.x.x - - [08/Feb/2018:17:05:05 -0800] "POST /293DA5867D8994284EF7A65144EAE7FEB802440A/comm/event/phViGabD.KeyPressed HTTP/1.1" 200 516 "-" "keep-alive"
x.x.x.x - - [08/Feb/2018:17:05:05 -0800] "POST /293DA5867D8994284EF7A65144EAE7FEB802440A/comm/event/phViGabD.KeyPressed HTTP/1.1" 200 516 "-" "keep-alive"
x.x.x.x - - [08/Feb/2018:17:05:06 -0800] "POST /293DA5867D8994284EF7A65144EAE7FEB802440A/comm/event/phViGabD.KeyPressed HTTP/1.1" 200 516 "-" "keep-alive"
x.x.x.x - - [08/Feb/2018:17:05:06 -0800] "POST /293DA5867D8994284EF7A65144EAE7FEB802440A/comm/event/phViGabD.KeyPressed HTTP/1.1" 200 516 "-" "keep-alive"
x.x.x.x - - [08/Feb/2018:17:05:07 -0800] "POST /293DA5867D8994284EF7A65144EAE7FEB802440A/comm/event/phViGabD.KeyPressed HTTP/1.1" 200 516 "-" "keep-alive"
x.x.x.x - - [08/Feb/2018:17:05:08 -0800] "POST /293DA5867D8994284EF7A65144EAE7FEB802440A/comm/event/phViGabD.KeyPressed HTTP/1.1" 200 516 "-" "keep-alive"
x.x.x.x - - [08/Feb/2018:17:05:08 -0800] "POST /293DA5867D8994284EF7A65144EAE7FEB802440A/comm/event/phViGabD.KeyPressed HTTP/1.1" 200 516 "-" "keep-alive"
x.x.x.x - - [08/Feb/2018:17:05:09 -0800] "POST /293DA5867D8994284EF7A65144EAE7FEB802440A/comm/event/eGKd91h6.Hidden HTTP/1.1" 200 2 "-" "keep-alive"

The log seems to show what I would expect: keypresses in the user name field, followed by a Tab into the Password field, and then keypresses in the Password field. But nowhere do I show any actions which would trigger my Login() method 7 times. This is very weird.

Hmm. Looking at my code, my Login() method is called from two places:

Button1.Action
   Login()

PasswordField.KeyPressed(Details as REALbasic.KeyEvent)
   select case details.KeyCode
      case details.KeyEnter
         Login()
   end select

From https://documentation.xojo.com/index.php/WebControl.KeyPressed I see it says:

A key was pressed and released in the control (this could be repeatedly if the user held down the key).

So I wonder if there is some sort of “key bounce” problem happening with Chrome browsers?

  • user types the username, tabs to the password field
  • types their password
  • hits the Enter key once
  • Instead of sending one event, Chrome sends multiple events (in this case, I’m seeing as many as 12 events over 2-3 seconds)

I believe the problem is solved. For some reason, the latest Xojo in conjunction with recent web browsers seem more prone to generating multiple KeyPressed() events. My code was not expecting this, and therefore caused multiple logins and showing a webPage multiple times, which caused problems.

The solution was to code defensively, by adding a boolean flag so that my Login() routine could only be called once, and checking the time so that it was not called more than once per second. I just ran another test with multiple users and they had zero problems.

I’ve submitted a feature request to make this easier: <https://xojo.com/issue/51429> WebApp KeyPressed flag to detect repeated events