Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-3561

JettyWebSocketServer uses original requested port, instead of the forwarded port

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.1.0
    • 1.2.0
    • Extensions

    Description

      Situation:
      We have port forwarding set up in such a way where port 25000 is forwarded to port 15000. ListenWebSocket processor listens on this 15000 port.

      Requests that hit the JettyWebSocketServer are considered as attempting to connect to the original port (25000) rather than the forwarded port of 15000. The same was reproduced with different ports and on different forwarding layers (i.e. NAT and iptables). I've included a stack trace below.

      From Koji:
      I think it's more of a Jetty side issue, after it upgrade HTTP connection to TCP, it still uses the original requested port (which is a port forwarding request to the real port) to find a request handler assigned to that port.
      (updated) Excuse me, but I was wrong about this diagnose. It's a problem in NiFi JettyWebSocketServer I wrote. The ControllerService lookups server instance by a port number that the CS listens to. When a request made through port forwarding, a port passed by ServletUpgradeRequest is different than CS is bounded to. Then it fails to lookup a server instance. I will check if original port can be retrieved from a request, if not, I will add a configuration property to the CS to specify forwarding port numbers.

      java.lang.RuntimeException: No controller service is bound with port: 25000
      at org.apache.nifi.websocket.jetty.JettyWebSocketServer$JettyWebSocketServlet.createWebSocket(JettyWebSocketServer.java:134) ~[nifi-websocket-services-jetty-1.1.0.2.1.2.0-10.jar:1.1.0.2.1.2.0-10]
      at org.eclipse.jetty.websocket.server.WebSocketServerFactory.acceptWebSocket(WebSocketServerFactory.java:187) ~[websocket-server-9.3.13.v20161014.jar:9.3.13.v20161014]
      at org.eclipse.jetty.websocket.server.WebSocketServerFactory.acceptWebSocket(WebSocketServerFactory.java:172) ~[websocket-server-9.3.13.v20161014.jar:9.3.13.v20161014]
      at org.eclipse.jetty.websocket.servlet.WebSocketServlet.service(WebSocketServlet.java:155) ~[websocket-servlet-9.3.13.v20161014.jar:9.3.13.v20161014]
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) ~[javax.servlet-api-3.1.0.jar:3.1.0]
      at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:845) ~[jetty-servlet-9.3.9.v20160517.jar:9.3.9.v20160517]
      at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:583) [jetty-servlet-9.3.9.v20160517.jar:9.3.9.v20160517]
      at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1174) [jetty-server-9.3.9.v20160517.jar:9.3.9.v20160517]
      at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:511) [jetty-servlet-9.3.9.v20160517.jar:9.3.9.v20160517]
      at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1106) [jetty-server-9.3.9.v20160517.jar:9.3.9.v20160517]
      at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [jetty-server-9.3.9.v20160517.jar:9.3.9.v20160517]
      at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:213) [jetty-server-9.3.9.v20160517.jar:9.3.9.v20160517]
      at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134) [jetty-server-9.3.9.v20160517.jar:9.3.9.v20160517]
      at org.eclipse.jetty.server.Server.handle(Server.java:524) [jetty-server-9.3.9.v20160517.jar:9.3.9.v20160517]
      at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:319) [jetty-server-9.3.9.v20160517.jar:9.3.9.v20160517]
      at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:253) [jetty-server-9.3.9.v20160517.jar:9.3.9.v20160517]
      at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:273) [jetty-io-9.3.9.v20160517.jar:9.3.9.v20160517]
      at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95) [jetty-io-9.3.9.v20160517.jar:9.3.9.v20160517]
      at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:93) [jetty-io-9.3.9.v20160517.jar:9.3.9.v20160517]
      at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executeProduceConsume(ExecuteProduceConsume.java:303) [jetty-util-9.3.9.v20160517.jar:9.3.9.v20160517]
      at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:148) [jetty-util-9.3.9.v20160517.jar:9.3.9.v20160517]
      at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:136) [jetty-util-9.3.9.v20160517.jar:9.3.9.v20160517]
      at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671) [jetty-util-9.3.9.v20160517.jar:9.3.9.v20160517]
      at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589) [jetty-util-9.3.9.v20160517.jar:9.3.9.v20160517]
      at java.lang.Thread.run(Thread.java:745) [na:1.8.0_111]

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            ijokarumawak Koji Kawamura
            orendain Edgar Orendain
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment