在Elastic Beanstalk上托管的节点JS服务器

时间:2016-12-01 14:11:22

标签: java node.js amazon-web-services httpurlconnection

我遇到了与Elastic Beanstalk服务器的连接问题。我正在AWS Elastic Beanstalk上运行一个服务器,只需一个简单的调用:

app.get('/WhatIsCool?', function (req, res) {
    res.send("You are cool!!!")
})

在Java方面我有

public String testing() {
    try {
        URL http = new URL(urladdress + "/WhatIsCool");
        HttpURLConnection openCon = (HttpURLConnection) http.openConnection();
        System.out.println(http);
        openCon.setRequestMethod("GET");
        openCon.setDoOutput(true);
        openCon.setConnectTimeout(60 * 1000);
        openCon.setReadTimeout(60 * 1000);
        System.out.println("Well I got this far.");
        BufferedReader br = new BufferedReader(new InputStreamReader(openCon.getInputStream()));
        System.out.println("Can I get this far?");
        while ((inputLine = br.readLine()) != null) {
            System.out.println("What is cool? " + inputLine);
            return inputLine;
        }
        br.close();
        return null;
    } catch (IOException e1) {
        e1.printStackTrace();
        return "Error: " + e1;
    }
}

但由于某种原因,我在#34之后的线路上一直收到错误;我走得很远#34;我不确定我做错了什么我在网上尝试了很多不同的东西但是它们似乎都没有用。我还应该提一下,当我在本地运行它时它工作得很好。

0 个答案:

没有答案