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

JettyWebSocketServer uses original requested port, instead of the forwarded port

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.1.0
    • Fix Version/s: 1.2.0
    • Component/s: Extensions
    • Labels:

      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]

        Issue Links

          Activity

          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user ijokarumawak opened a pull request:

          https://github.com/apache/nifi/pull/1568

          NIFI-3561: Fix WS port forwarding

          Fixed service instance lookup to use local port so that it works when
          it is accessed through port forwarding.

          Thank you for submitting a contribution to Apache NiFi.

          In order to streamline the review of the contribution we ask you
          to ensure the following steps have been taken:

              1. For all changes:
          • [x] Is there a JIRA ticket associated with this PR? Is it referenced
            in the commit message?
          • [x] Does your PR title start with NIFI-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
          • [x] Has your PR been rebased against the latest commit within the target branch (typically master)?
          • [x] Is your initial contribution a single, squashed commit?
              1. For code changes:
          • [ ] Have you ensured that the full suite of tests is executed via mvn -Pcontrib-check clean install at the root nifi folder?
          • [ ] Have you written or updated unit tests to verify your changes?
          • [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
          • [ ] If applicable, have you updated the LICENSE file, including the main LICENSE file under nifi-assembly?
          • [ ] If applicable, have you updated the NOTICE file, including the main NOTICE file found under nifi-assembly?
          • [ ] If adding new Properties, have you added .displayName in addition to .name (programmatic access) for each of the new properties?
              1. For documentation related changes:
          • [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
              1. Note:
                Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/ijokarumawak/nifi nifi-3561

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/nifi/pull/1568.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #1568


          commit 590f0e9d471d422228ea59c576b4f91c5d279022
          Author: Koji Kawamura <ijokarumawak@apache.org>
          Date: 2017-03-07T08:08:47Z

          NIFI-3561: Fix WS port forwarding

          Fixed service instance lookup to use local port so that it works when
          it is accessed through port forwarding.


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user ijokarumawak opened a pull request: https://github.com/apache/nifi/pull/1568 NIFI-3561 : Fix WS port forwarding Fixed service instance lookup to use local port so that it works when it is accessed through port forwarding. Thank you for submitting a contribution to Apache NiFi. In order to streamline the review of the contribution we ask you to ensure the following steps have been taken: For all changes: [x] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message? [x] Does your PR title start with NIFI-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character. [x] Has your PR been rebased against the latest commit within the target branch (typically master)? [x] Is your initial contribution a single, squashed commit? For code changes: [ ] Have you ensured that the full suite of tests is executed via mvn -Pcontrib-check clean install at the root nifi folder? [ ] Have you written or updated unit tests to verify your changes? [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0] ( http://www.apache.org/legal/resolved.html#category-a)? [ ] If applicable, have you updated the LICENSE file, including the main LICENSE file under nifi-assembly? [ ] If applicable, have you updated the NOTICE file, including the main NOTICE file found under nifi-assembly? [ ] If adding new Properties, have you added .displayName in addition to .name (programmatic access) for each of the new properties? For documentation related changes: [ ] Have you ensured that format looks appropriate for the output in which it is rendered? Note: Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible. You can merge this pull request into a Git repository by running: $ git pull https://github.com/ijokarumawak/nifi nifi-3561 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/nifi/pull/1568.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #1568 commit 590f0e9d471d422228ea59c576b4f91c5d279022 Author: Koji Kawamura <ijokarumawak@apache.org> Date: 2017-03-07T08:08:47Z NIFI-3561 : Fix WS port forwarding Fixed service instance lookup to use local port so that it works when it is accessed through port forwarding.
          Hide
          joewitt Joseph Witt added a comment -

          added fix version of 1.2.0 due to community submission, PR ready. Needs review. Thanks!

          Show
          joewitt Joseph Witt added a comment - added fix version of 1.2.0 due to community submission, PR ready. Needs review. Thanks!
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 7c19796eb22ced9aba703e52e76e58450e34d018 in nifi's branch refs/heads/master from Koji Kawamura
          [ https://git-wip-us.apache.org/repos/asf?p=nifi.git;h=7c19796 ]

          NIFI-3561: Fix WS port forwarding

          Fixed service instance lookup to use local port so that it works when
          it is accessed through port forwarding.

          This fixes: #1568

          Signed-off-by: Andre F de Miranda <trixpan@users.noreply.github.com>

          Show
          jira-bot ASF subversion and git services added a comment - Commit 7c19796eb22ced9aba703e52e76e58450e34d018 in nifi's branch refs/heads/master from Koji Kawamura [ https://git-wip-us.apache.org/repos/asf?p=nifi.git;h=7c19796 ] NIFI-3561 : Fix WS port forwarding Fixed service instance lookup to use local port so that it works when it is accessed through port forwarding. This fixes: #1568 Signed-off-by: Andre F de Miranda <trixpan@users.noreply.github.com>
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user asfgit closed the pull request at:

          https://github.com/apache/nifi/pull/1568

          Show
          githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/nifi/pull/1568
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user trixpan commented on the issue:

          https://github.com/apache/nifi/pull/1568

          @ijokarumawak thanks for fixing this. merged

          Show
          githubbot ASF GitHub Bot added a comment - Github user trixpan commented on the issue: https://github.com/apache/nifi/pull/1568 @ijokarumawak thanks for fixing this. merged

            People

            • Assignee:
              ijokarumawak Koji Kawamura
              Reporter:
              orendain Edgar Orendain
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development