Error receiving a response to a text translation request at Yandex translator:
HTTP / 1.1 503 SERVICE UNAVAILABLE [Server: nginx / 1.6.2, Content-Type: text / html; charset = utf-8, Content-Length: 0, Connection: keep-alive, Keep-Alive: timeout = 120, X-Content-Type-Options: nosniff, Date: Sun, 16 Oct 2016 09:57:17 GMT] org.apache.http.conn.BasicManagedEntity@4250f136
public String request(String str, String key, String lang) throws Exception{ @SuppressWarnings({ "resource", "deprecation" }) HttpClient client = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(PATH); httpPost.setHeader("User-Agent", "Mozilla/5.0"); List<NameValuePair> params = new ArrayList<>(); params.add(new BasicNameValuePair("key", key)); params.add(new BasicNameValuePair("lang", lang)); params.add(new BasicNameValuePair("format", "html")); params.add(new BasicNameValuePair("text", str)); httpPost.setEntity(new UrlEncodedFormEntity(params, Consts.UTF_8)); HttpResponse httpResponse = client.execute(httpPost); BufferedReader br = new BufferedReader(new InputStreamReader(httpResponse .getEntity().getContent(), "UTF-8")); //System.out.println(br.readLine()); String string = br.readLine(); return string; } I assume that you need to increase the timeout from the server, but I do not know how. The request is formed correctly as an error occurs only for some texts to be translated.
wget -qO - "https://translate.yandex.net/api/v1.5/tr.json/translate?key=$key&text=$text&lang=ru"- PinkTuxwgeton the command line (if windows - google "wget for windows"), instead of$key- your key, instead of$text- text. It is desirable to add-Sto the-qO -parameters. - PinkTux