#1395 Problem with WispService or just white noise?

msl Tue 18 Jan 2011

Not sure if this is anything to be concerned by, but if I start up multiple WispServices, on shutdown an error is logged.

Sample code:

// Main.fan

class Main {

    Void main() {
        test(8888)
        test(9999)
    }

    Void test(Int p) {

        wisp := wisp::WispService {
            port = p
            root = webmod::FileMod {
                file = `./Main.fan`.toFile
            }
        }

        wisp.start

        c := web::WebClient(`http://localhost:${p}`)
        echo(c.getBuf.readLine + " ...")
        c.close

        /* Same error with a browser or telnet */
        /*
        echo("Open your browser and go to http://localhost:${p}")
        concurrent::Actor.sleep(15sec)
        */

        wisp.uninstall
    }

}

and the output:

[16:55:51 18-Jan-11] [info] [web] WispService started on port 8888
// Main.fan ...
[16:55:51 18-Jan-11] [info] [web] WispService stopped on port 8888
[16:55:51 18-Jan-11] [info] [web] WispService started on port 9999
// Main.fan ...
[16:55:51 18-Jan-11] [err] [web] WispService accept on 9999
  sys::IOErr: java.net.SocketException: Socket closed
    java.net.PlainSocketImpl.socketAccept (PlainSocketImpl.java)
    java.net.PlainSocketImpl.accept (PlainSocketImpl.java:390)
    java.net.ServerSocket.implAccept (ServerSocket.java:453)
    inet::TcpListenerPeer.doAccept (TcpListenerPeer.java:97)
    inet::TcpListener.doAccept (TcpListener.fan)
    inet::TcpListener.accept (TcpListener.fan:71)
    wisp::WispService.listen (WispService.fan:96)
    wisp::WispService.onStart (WispService.fan:50)
    fan.sys.Func$Indirect0.call (Func.java:128)
    concurrent::Actor.receive (Actor.java:99)
    concurrent::Actor._dispatch (Actor.java:225)
    concurrent::Actor._work (Actor.java:196)
    concurrent::ThreadPool$Worker.run (ThreadPool.java:255)
[16:55:51 18-Jan-11] [info] [web] WispService stopped on port 9999

msl Wed 19 Jan 2011

A bit more investigation - it's avoidable noise.

When the service is stopped via wisp::WispService.onStop it executes:

try closeTcpListener;    catch (Err e) log.err("WispService stop listener socket", e)
try listenerPool.stop;   catch (Err e) log.err("WispService stop listener pool", e)

and the accept loop inside wisp::WispService.listen catches exceptions via:

if (!listenerPool.isStopped)
    log.err("WispService accept on ${port}", e)

However, the connection is closed (by wisp::WispService.closeTcpListener) before the listener pool is stopped, so the if() check passes and the exception is logged.

The naive solution would be to swap the order of the two lines above in wisp::WispService.onStop but not sure if that is semantically equivalent.

Martin

brian Wed 19 Jan 2011

Switching shutdown order is good idea. But probably also a good idea to check the TcpListener socket too.

Try out this changeset

msl Fri 21 Jan 2011

That's done the trick - thanks

Login or Signup to reply.