{"action":"created","issue":{"url":"https://api.github.com/repos/ib-controller/ib-controller/issues/22","labels_url":"https://api.github.com/repos/ib-controller/ib-controller/issues/22/labels{/name}","comments_url":"https://api.github.com/repos/ib-controller/ib-controller/issues/22/comments","events_url":"https://api.github.com/repos/ib-controller/ib-controller/issues/22/events","html_url":"https://github.com/ib-controller/ib-controller/issues/22","id":65288383,"number":22,"title":"Using ssh forwarding - The remote host closed the connection","user":{"login":"ibizaman","id":1044950,"avatar_url":"https://avatars.githubusercontent.com/u/1044950?v=3","gravatar_id":"","url":"https://api.github.com/users/ibizaman","html_url":"https://github.com/ibizaman","followers_url":"https://api.github.com/users/ibizaman/followers","following_url":"https://api.github.com/users/ibizaman/following{/other_user}","gists_url":"https://api.github.com/users/ibizaman/gists{/gist_id}","starred_url":"https://api.github.com/users/ibizaman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ibizaman/subscriptions","organizations_url":"https://api.github.com/users/ibizaman/orgs","repos_url":"https://api.github.com/users/ibizaman/repos","events_url":"https://api.github.com/users/ibizaman/events{/privacy}","received_events_url":"https://api.github.com/users/ibizaman/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-03-30T19:53:51Z","updated_at":"2015-03-31T21:02:53Z","closed_at":null,"body":"Hi,\r\n\r\nI know this is strictly speaking not relative to ibcontroller but since you mention this tip in the README itself, maybe you already tried this method and already stumbled and overcomed the problem I have.\r\n\r\nSo I would like to connect to the ibgateway running on a remote server thanks to ssh forwarding. On the client where I want to connect the API, I run this command:\r\n``` bash\r\n$ ssh -L 4001:localhost:4001 me@192.168.1.2 -N\r\n```\r\nThe ssh connection is established but when trying to connect the API, I get an error (retrieved by the EWrapper method \"error\"):\r\n```\r\nid: -1, errorCode: 502, errorString: The remote host closed the connection\r\n```\r\n\r\nTo debug this, I tried:\r\n* connecting to the ibgateway from the server itself and it works.\r\n* forwarding something else like the webserver running on the server machine and it works:\r\n``` bash\r\n$ ssh -L 4001:localhost:80 me@192.168.1.2 -N\r\n$ curl localhost:4001\r\n```\r\nThis outputs the correct html page.\r\nSo for me, the ssh tunnel works as expected and the ibgateway also. But there must be something I'm missing. Do you have any idea what could it be?\r\n\r\nHere is my .ini, in case it could help:\r\n```\r\nLogToConsole=yes\r\nFIX=no\r\nPasswordEncrypted=no\r\nFIXLoginId=\r\nFIXPassword=\r\nFIXPasswordEncrypted=yes\r\nStoreSettingsOnServer=no\r\nMinimizeMainWindow=yes\r\nExistingSessionDetectedAction=primary\r\nAcceptIncomingConnectionAction=accept\r\nShowAllTrades=no\r\nIbAutoClosedown=no\r\nClosedownAt=\r\nAllowBlindTrading=yes\r\nDismissPasswordExpiryWarning=yes\r\nDismissNSEComplianceNotice=yes\r\nIbControlFrom=\r\nIbBindAddress=127.0.0.1\r\nCommandPrompt=\r\nSuppressInfoMessages=no\r\n```"},"comment":{"url":"https://api.github.com/repos/ib-controller/ib-controller/issues/comments/88245567","html_url":"https://github.com/ib-controller/ib-controller/issues/22#issuecomment-88245567","issue_url":"https://api.github.com/repos/ib-controller/ib-controller/issues/22","id":88245567,"user":{"login":"ibizaman","id":1044950,"avatar_url":"https://avatars.githubusercontent.com/u/1044950?v=3","gravatar_id":"","url":"https://api.github.com/users/ibizaman","html_url":"https://github.com/ibizaman","followers_url":"https://api.github.com/users/ibizaman/followers","following_url":"https://api.github.com/users/ibizaman/following{/other_user}","gists_url":"https://api.github.com/users/ibizaman/gists{/gist_id}","starred_url":"https://api.github.com/users/ibizaman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ibizaman/subscriptions","organizations_url":"https://api.github.com/users/ibizaman/orgs","repos_url":"https://api.github.com/users/ibizaman/repos","events_url":"https://api.github.com/users/ibizaman/events{/privacy}","received_events_url":"https://api.github.com/users/ibizaman/received_events","type":"User","site_admin":false},"created_at":"2015-03-31T21:02:53Z","updated_at":"2015-03-31T21:02:53Z","body":"@shevkoplyas I installed IbPy (nice little program btw!) and tried to follow your steps but I think I'm missing something.\r\n\r\nIn my setup, the server (192.168.1.2) is running one paper instance of TWS:\r\n``` bash\r\n$ netstat -nap | grep java | grep LIST\r\ntcp6       0      0 :::4001                 :::*          LISTEN      4096/java\r\ntcp6       0      0 127.0.0.1:7464          :::*          LISTEN      4096/java\r\n```\r\nIt looks already different than the output of your command: here I have the TWS instance listening on port 4003 and (I suppose) the IBController command server listening on port 7464.\r\n\r\nThen you create the tunnel but I don't get the correspondance between what you say in the text and the command you pasted:\r\n> Lets create tunnel from client (listening on std port 7462 so we don't need to modify python examples) to the playbox (which runs 2 TWS java apps on :1234 and :1234 ports)\r\nssh -L 7496:localhost:7462 dmitry@playbox -N\r\n\r\nWhere do you get your 7462 port? Is that the IBController command server like the 7464 for me? In that case, I don't get why you forward to that port, I would say in your case that the command should be: `ssh -L 7496:localhost:1234 dmitry@playbox -N` ?\r\n\r\nNevermind, I tried the two following tunnels:\r\n```\r\nssh -L 7496:localhost:4001 me@192.168.1.2 -N\r\nssh -L 7496:localhost:7464 me@192.168.1.2 -N\r\n```\r\nIn the first case, IbPy said it is not connected: `<error id=-1, errorCode=502, errorMsg=Couldn't connect to TWS ...>` while my application said `[error] id: -1, codeInt: 502, errorString: The remote host closed the connection`.\r\nIn the second cas, IbPy simply blocks on the `.connect()` method while my application is a little bit more chatty: `[error] id: -1, codeInt: 502, errorString: Protocol not supported`.\r\n\r\nSorry for nitpicking your post but I'm frankly going crazy right now. :)\r\n\r\n@rlktradewright You're totally correct. This has nothing to do with IBController but since the ssh tunnel process was mentioned in the README I thought somebody could easily spot my mistake."}}