jetty: Shit happens!!

For the impatient readers:

Don’t set Jetty’s <stopPort> to the same <port> where Jetty is running or you might run into some nasty-hard-to-debug problem.


Now a full explanation:

Imagine the following scenario,

Here we have to web services, A and B, both running on the same machine on Jetty webserver and one of them is listening for petitions on port 9090 (configured via de maven-jetty-plugin). Web service A has to request some data to B and process its reply. Nothing unusual.

So A issue a request to http://localhost:9090/<path> expecting an XML response as a result of doing it. But it gets nothing, nada, nichts.


Well, at this moment the first thing that came through my mind was that I did something wrong while coding or configurating any of the web services. So I checked everything, but it seemed right. My next move was to create a fake request with curl just to see what happened.

What happened misleaded me even more: web service B was responding. WTF!!

So I went one level down. I ran tcpdump. And what I got? I discovered that the main difference between the requests issued by web service A and curl was the ip version they used: web service A was using ipv4 and curl ipv6.

To force both requests (from the web service and curl) to use ipv4, I run curl against the web service B but now instead of localhost I used 127.0.0.1. And the response was empty, just like if the request came from web service A.


So I thought that all of my troubles had to do with the ip stack beeing used. And I wasted some hours
trying to figure out what was wrong with it.
As I was really desperate with all this, I download Jetty sources to debug it on eclipse. I wanted to know
what was happening with my requests. And here was were light came to me by chance. While debugging Jetty,
an incomming connection from  internet arraived to my <public_ip>:9090  (I guess it was someone doing some kind of portscanning) and got stuck on my breakpoints…

Mmmm, wait a moment…

Yep, internet addresses are ipv4 only (for most of us), so this ruled out any kind of problem with the ipv4 stack or shit. Now I began to see the light. This was some mess with the adresses.

Just to check I did an alias in my loopback interface to 127.0.0.2 and run again the request with curl to that ip. This time being successful. Ooook.

So, whats wrong with 127.0.0.1:9090?

Netstat output,

13:29:46 ~ $ netstat -f inet -an
Active Internet connections (including servers)
Proto Recv-Q Send-Q  Local Address          Foreign Address        (state)
tcp4       0      0  127.0.0.1.9090         *.*                    LISTEN
tcp46      0      0  *.9090                 *.*                    LISTEN
...

Lsof output,

13:49:39 ~ $ lsof -i :9090
COMMAND PID     USER   FD   TYPE     DEVICE SIZE/OFF NODE NAME
java    239 madtrick   94u  IPv6 0x08c10f80      0t0  TCP *:websm (LISTEN)
java    239 madtrick   95u  IPv6 0x08c11460      0t0  TCP [::127.0.0.1]:websm (LISTEN)

I have two sockets listening on port 9090 and both belong to the same process (as reported by lsof), my Jetty Server.  But requests to 127.0.0.1:9090 are lost meanwhile requests to <any_other_ip>:9090 are processed by the server.

Lets try something, lets change the <stopPort> to 9091 and see what happens…
Request from web service A, OK.
Request from curl, OK.

Run netstat again,

13:59:50 ~ $ netstat -f inet -an
Active Internet connections (including servers)
Proto Recv-Q Send-Q  Local Address          Foreign Address        (state)
tcp4       0      0  127.0.0.1.9091         *.*                    LISTEN
tcp46      0      0  *.9090                 *.*                    LISTEN
...

And lsof for ports 9090 and 9091,

14:00:48 ~ $ lsof -i :9090
COMMAND PID     USER   FD   TYPE     DEVICE SIZE/OFF NODE NAME
java    301 madtrick   93u  IPv6 0x08c10f80      0t0  TCP *:websm (LISTEN)
14:00:55 ~ $ lsof -i :9091
COMMAND PID     USER   FD   TYPE     DEVICE SIZE/OFF NODE NAME
java    301 madtrick   94u  IPv6 0x08c11460      0t0  TCP [::127.0.0.1]:xmltec-xmlmail (LISTEN)

So you see, Jetty opens another socket which listens on 127.0.0.1:<stopPort>  (lets call it jetty stop daemon) and being that an explicit address it has precedence over the catch all 0.0.0.0:9090 (where Jetty is listening). That’s why my requests to 127.0.0.1:9090 returned nothing.

This is what was happening before,

And this is whats happens now,

Category: java, programacion, shit 23 comments »

23 Responses to “jetty: Shit happens!!”

  1. Smoowhop

    must check kmXTaOsm [URL=http://prada1outlet2online.medykblog.pl/ – prada outlet usa[/URL – to your friends ysVxXzwF [URL=http://prada1outlet2online.medykblog.pl/ – http://prada1outlet2online.medykblog.pl/ [/URL -

  2. Zerprese

    buy [URL=http://burberrytrenchcoat.devhub.com/ – burberry shirt[/URL – to your friends dOxKfrmT [URL=http://burberrytrenchcoat.devhub.com/ – http://burberrytrenchcoat.devhub.com/ [/URL -

  3. kantToff

    you must read [URL=http://blogg.sweside.com/coachbagsoutletonlinehh/ – outlet coach[/URL – to take huge discount fOotPqrV [URL=http://coachoutlethh.metroblog.com/ – http://worldmusicblog.net/coachhandbagsoutletonlineyu/ [/URL -

  4. Freniefe

    you definitely love [URL=http://worldmusicblog.net/coachonlinehh/ – coach bags outlet online[/URL – suprisely DLYbcEVx [URL=http://coachhandbagsonlinehh.iwannayou.com/ – http://coachbagsoutletkk.blag.gy/ [/URL -

  5. brubjege

    check [URL=http://crowdpulp.com/burberryjacket85/ – burberry factory outlet[/URL – to your friends oUfvOeex [URL=http://burberrycoat85.newsblog.com/ – http://burberrytrench85.blag.gy/ [/URL -

  6. Annefalf

    buy a [URL=http://autoresponders.pro/free/burberryonline85/ – burberry outlet[/URL – for less IlcOgBrd [URL=http://burberryjacket85.urbanblog.dk/ – http://burberrytrench85.iwannayou.com/ [/URL -

  7. Univilla

    get [URL=http://buylouisvuittononline.bloglines.co.za/ – buy louis vuitton online[/URL – for less OorbhqPI [URL=http://wheretobuylouisvuitton.techmaza.in/ – http://wheretobuylouisvuitton.xanga.com/ [/URL -

  8. rofemopy

    buy best [URL=http://buylouisvuitton.livejournal.com/ – buy louis vuitton handbags[/URL – to get new coupon cwBRbGYX [URL=http://buylouisvuitton.livejournal.com/ – http://buylouisvuitton.livejournal.com/ [/URL -

  9. anedegek

    buy a [URL=http://buylouisvuitton.livejournal.com/ – buy louis vuitton handbags[/URL – , just clicks away BSedfMXt [URL=http://buylouisvuitton.livejournal.com/ – http://buylouisvuitton.livejournal.com/ [/URL -

  10. deetuago

    must check [URL=http://worldmusicblog.net/buylouisvuittononline/2012/11/16/buy-louis-vuitton-onlinecheap-lv-handbags-with-the-perfect-fabricshigh-quality-low-price/ – buy louis vuitton online[/URL – to get new coupon zhJDJMkZ [URL=http://louisvuittonbuy.tsublog.tsukaeru.net/ – http://erekod.smkseta.com/buylouisvuitton/ [/URL -

  11. Ribchica

    check this link, [URL=http://burberrytrenchcoat.devhub.com/ – burberry men[/URL – , just clicks away enzCtJUu [URL=http://burberrytrenchcoat.devhub.com/ – http://burberrytrenchcoat.devhub.com/ [/URL -

  12. TubTwiRl

    check [URL=http://burberrywallet85.mzk-pulawy.pl/ – burberry coat[/URL – and get big save eWPXmIjT [URL=http://burberryboots85.ahoban.com/posts/3 – http://decrypteurdetendances.com/burberrywallet85/ [/URL -

  13. Erafebra

    I’m sure the best for you [URL=http://coachhandbagsoutletkk.ahoban.com/posts/3 – coach online[/URL – to get new coupon VpIpZokt [URL=http://coachhandbagsonlinehh.iwannayou.com/ – http://coachoutlethh.metroblog.com/ [/URL -

  14. Univilla

    you will like [URL=http://louisvuittonbuyonline.biztro.com.au/ – buy louis vuitton handbags[/URL – to your friends uXhhdVuk [URL=http://worldmusicblog.net/buylouisvuittononline/2012/11/16/buy-louis-vuitton-onlinecheap-lv-handbags-with-the-perfect-fabricshigh-quality-low-price/ – http://louisvuittonbuy.medykblog.pl/ [/URL -

  15. brubjege

    order an [URL=http://krishnacommunity.com/burberrypolo85/ – burberry polo[/URL – for promotion code ZLsGyOCN [URL=http://burberrytie85.tsublog.tsukaeru.net/ – http://burberrytie85.tsublog.tsukaeru.net/ [/URL -

  16. chilelitheatO

    ???????? ?? ?????????? ?????? ???????, ????? ?????? ?????? ?????. ????????????? ?????? ?????????. ????? ????????????? ?????? ????????. ???? ????????? ???????? ? ???????? ?? ?????? ?? ????????, ???????? ?? ??? ? ???? (??? ????? ?? ??? ???). ???????? ??? ???????????? ???????????.
    http://igroto4ka.ru/wp-content/uploads/2012/02/mist2-300×147.jpg

  17. Nupdyexy

    sell [URL=http://burberrytrenchcoat.devhub.com/ – burberry outlet[/URL – for gift hTsmWJSX [URL=http://burberrytrenchcoat.devhub.com/ – http://burberrytrenchcoat.devhub.com/ [/URL -

  18. payopecy

    cheap [URL=http://buylouisvuitton.livejournal.com/ – buy louis vuitton bags[/URL – to take huge discount SKZMLXQP [URL=http://buylouisvuitton.livejournal.com/ – http://buylouisvuitton.livejournal.com/ [/URL -

  19. leadvaxy

    must look at this [URL=http://burberrytrenchcoat.devhub.com/ – burberry t shirt[/URL – suprisely HUkYzDsp [URL=http://burberrytrenchcoat.devhub.com/ – http://burberrytrenchcoat.devhub.com/ [/URL -

  20. Usemnrom

    cheap [URL=http://erekod.smkseta.com/guccishoponlinety/ – gucci online[/URL – for less XLUufxqM [URL=http://guccioutletqq.besthometreadmill.co.za/ – http://www.arunavi.jp/twiyodogawa/guccionlinety/ [/URL -

  21. BraryRuh

    you must read [URL=http://www.blogvan.nl/coachpursesoutletonlinekk/ – coach bags outlet online[/URL – , just clicks away vgGRkCwQ [URL=http://www.arunavi.jp/twiyodogawa/coachpurseoutletonlineyu – http://www.arunavi.jp/twiyodogawa/coachpurseoutletonlineyu [/URL -

  22. tafowege

    sell [URL=http://erekod.smkseta.com/buylouisvuitton/ – where to buy louis vuitton bags[/URL – , for special offer QclaZSCQ [URL=http://buylouisvuittononline.bloglines.co.za/ – http://www.photoblog.com/buylouisvuitton [/URL -

  23. christianlouboutinoutl

    Following, consider the shade and structure of the meat. A wonderful steak should certainly be company towards the touch, moist, and vivid in shade. It have to be well marbled with skinny streaks of white body fat all through plus a skinny crust of meat around the exterior. In our additional fat informed culture, we are most likely to show up for lean cuts of meat, however the skinny streaks of white excess fat marbled throughout the meat christian louboutin shoes will certainly be the vital in to a tender juicy meat. christian louboutin outlet store http://www.christianlouboutinoutlet2013shop.com/


Leave a Reply