title: Scraping a site
body: <p>I am trying to write an alert system to scrape complaints board site periodically to look for any complaints about my product. I am using Jsoup for the same. Below is the the code fragment that gives me error.</p>
  
  <pre><code>doc = Jsoup.connect(finalUrl).timeout(10 * 1000).get();
  </code></pre>
  
  <p>This gives me error</p>
  
  <pre><code>java.net.SocketException: Unexpected end of file from server
  </code></pre>
  
  <p>When I copy paste the same finalUrl String in the browser, it works. I then tried simple URL connection </p>
  
  <pre><code>            BufferedReader br = null;
              try {
                  URL a = new URL(finalUrl);
                  URLConnection conn = a.openConnection();
  
                  // open the stream and put it into BufferedReader
                  br = new BufferedReader(new InputStreamReader(
                          conn.getInputStream()));
                  doc = Jsoup.parse(br.toString());
              } catch (IOException e) {
                  e.printStackTrace();
              }
  </code></pre>
  
  <p>But as it turned out, the connection itself is returning null (br is null). Now the question is, why does the same string when copy pasted in browser opens the site without any error? </p>
  
  <p>Full stacktrace is as below:</p>
  
  <pre><code>java.net.SocketException: Unexpected end of file from server
      at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:774)
      at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:633)
      at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:771)
      at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:633)
      at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1195)
      at ComplaintsBoardScraper.main(ComplaintsBoardScraper.java:46)
  </code></pre>