{"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":8,"created_at":"2015-03-30T19:53:51Z","updated_at":"2015-04-01T19:44:17Z","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/88608005","html_url":"https://github.com/ib-controller/ib-controller/issues/22#issuecomment-88608005","issue_url":"https://api.github.com/repos/ib-controller/ib-controller/issues/22","id":88608005,"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-04-01T19:44:17Z","updated_at":"2015-04-01T19:44:17Z","body":"Unfortunately your guess on step 2 is incorrect.\r\n\r\nIn fact I was going to write a long post about what I tried but in the meantime, I resolved the problem. The solution is simple but quite disappointing at the same time.\r\n\r\nSee that `localhost` in the ssh tunnel command? Well, in fact that's the problem. When using `127.0.0.1`, it works fine... So the correct command is for me:\r\n```\r\nssh -L 7496:127.0.0.1:4001 me@192.168.1.2 -N\r\n```\r\nI can understand, from a programmer point of view, that if there's a bind on \"127.0.0.1\" in my config it requires the exact same match. But still, why is it working for you then?\r\n\r\n@rlktradewright I am very sorry. You are completely right. I saw it on [ibcontroller-aur](https://github.com/benalexau/ibcontroller-aur)'s README."}}