Web2 Response.Write nil object exception in HandleURL

In 2021r1.1 / Ubuntu 20.04
I have the following code in HandleURL in a web app (WebApp1) set to port 10000:

Response.Write "Hello world"
return true

It returns “Hello world” in my web browser as expected.

In another web app on port 8080 (WebApp2) I have subclassed a URLConnection and called it “URLConnect”. (A great imagination I have). The subclass has the following method:

Sub test()
End Sub

The subclsss is instantiated in the web apps HandleURL like so:

Function HandleURL(Request As WebRequest, Response As WebResponse) As Boolean
  dim URLConnect1 as new UrlConnect
  Response.Write "Done "
  return true
End Function

The subclass’s ContentReceived event handler contains the following line:

Print content

So when run form the debugger WebApp2 returns “Done” to the browser as expected.

NOW HERE’S THE KICKER: I get a nil object exception on Response.Write "Hello world" in WebApp1 even though it’s supposed to be over the wire, so no content bis printed in WebApp2.

But wait, there’s more: If I put a break point at print content in WebApp2’s Content Received event handler, WebApp2 breaks not there but on its Response.Write "Done " in HandleURL with a NilObjectException.

If I get rid of the super. prefix from the send command, WebApp2 breaks on its Response.Write "Done " in HandleURL with a NillObjectException.

Have I done something wrong? The breaking effect of WebApp2 on WebApp1 doesn’t seem explainable by my stupidity alone… :stuck_out_tongue_closed_eyes:

You probably want to use SendSync rather than Send. I’d guess that because Webapp2 isn’t waiting for the response the response mechanism no longer has a socket to respond on thus your NOE.

Thanks Wayne, I’ll look into it.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.