{"action":"created","issue":{"url":"https://api.github.com/repos/spray/spray/issues/993","labels_url":"https://api.github.com/repos/spray/spray/issues/993/labels{/name}","comments_url":"https://api.github.com/repos/spray/spray/issues/993/comments","events_url":"https://api.github.com/repos/spray/spray/issues/993/events","html_url":"https://github.com/spray/spray/issues/993","id":54982614,"number":993,"title":"Unnecessary reverse DNS query when connecting by IP with SSL","user":{"login":"briandignan","id":5083022,"avatar_url":"https://avatars.githubusercontent.com/u/5083022?v=3","gravatar_id":"","url":"https://api.github.com/users/briandignan","html_url":"https://github.com/briandignan","followers_url":"https://api.github.com/users/briandignan/followers","following_url":"https://api.github.com/users/briandignan/following{/other_user}","gists_url":"https://api.github.com/users/briandignan/gists{/gist_id}","starred_url":"https://api.github.com/users/briandignan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/briandignan/subscriptions","organizations_url":"https://api.github.com/users/briandignan/orgs","repos_url":"https://api.github.com/users/briandignan/repos","events_url":"https://api.github.com/users/briandignan/events{/privacy}","received_events_url":"https://api.github.com/users/briandignan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-01-21T06:28:33Z","updated_at":"2015-01-21T07:34:27Z","closed_at":null,"body":"When connecting to a SSL server with the spray client by IP address, an unnecessary reverse DNS query is performed to lookup the hostname for the given IP.  The query happens after the TCP 3-way handshake completes, and in some cases several seconds later. In my testing, it typically happens 4 seconds later (like in the attached packet capture screenshot) and sometimes causes the session to timeout, because it blocks the request from being sent. Other times the request completes but takes much longer than it should because of the query. \r\n\r\n![wireshark-capture](https://cloud.githubusercontent.com/assets/5083022/5831895/9149fa26-a109-11e4-9cc8-4610c6c4bd4f.png)\r\n\r\nThe DNS query is caused by a call to the java.net.InetSocketAddress.getHostName() in spray.io.SslTlsSupport.scala.  From the Javadoc for InetSocketAddress.getHostName():\r\n\r\n\"Note: This method may trigger a name service reverse lookup if the address was created with a literal IP address.\"\r\n\r\nhttp://download.java.net/jdk7/archive/b123/docs/api/java/net/InetSocketAddress.html#getHostName()\r\n\r\nThe actual behavior and delay with the DNS query might vary by operating system. I'm running OSX 10.9.5 with JRE version 1.7.0_67.  \r\n\r\nI'll submit a PR for a fix. Also, I'm pretty new to the open source scene, so please let me know if I should be doing anything differently with the issue report or PR.  I did some manual testing after locally committing a fix using hostname and IP address, and both seem to work fine. "},"comment":{"url":"https://api.github.com/repos/spray/spray/issues/comments/70795999","html_url":"https://github.com/spray/spray/issues/993#issuecomment-70795999","issue_url":"https://api.github.com/repos/spray/spray/issues/993","id":70795999,"user":{"login":"briandignan","id":5083022,"avatar_url":"https://avatars.githubusercontent.com/u/5083022?v=3","gravatar_id":"","url":"https://api.github.com/users/briandignan","html_url":"https://github.com/briandignan","followers_url":"https://api.github.com/users/briandignan/followers","following_url":"https://api.github.com/users/briandignan/following{/other_user}","gists_url":"https://api.github.com/users/briandignan/gists{/gist_id}","starred_url":"https://api.github.com/users/briandignan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/briandignan/subscriptions","organizations_url":"https://api.github.com/users/briandignan/orgs","repos_url":"https://api.github.com/users/briandignan/repos","events_url":"https://api.github.com/users/briandignan/events{/privacy}","received_events_url":"https://api.github.com/users/briandignan/received_events","type":"User","site_admin":false},"created_at":"2015-01-21T07:34:27Z","updated_at":"2015-01-21T07:34:27Z","body":"I don't know where I went wrong when I first ran the tests, but they're all passing now. "}}