Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/324.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 发出从节点向Jetty发送REST请求_Java_Node.js_Rest_Jetty_Jersey 2.0 - Fatal编程技术网

Java 发出从节点向Jetty发送REST请求

Java 发出从节点向Jetty发送REST请求,java,node.js,rest,jetty,jersey-2.0,Java,Node.js,Rest,Jetty,Jersey 2.0,从Node.js向Jetty发送REST(POST)请求时,我遇到了一个问题。当我从REST客户端发送相同的请求时,它工作正常。 以下是节点js代码: var postheaders = { 'Content-Type' : 'application/json', 'Content-Length' : Buffer.byteLength(jsonObject, 'utf8') }; var optionsPost = { host : '127.0.0.1', /

从Node.js向Jetty发送REST(POST)请求时,我遇到了一个问题。当我从REST客户端发送相同的请求时,它工作正常。 以下是节点js代码:

    var postheaders = {
    'Content-Type' : 'application/json',
    'Content-Length' : Buffer.byteLength(jsonObject, 'utf8')
};
var optionsPost = {
    host : '127.0.0.1', // here only the domain name
    // (no http/https !)
    port : 8080,
    path : '/external/session', // the rest of the url with parameters if needed
    method : 'POST', // do GET
    headers :postheaders    
};

console.info('Options prepared:');
console.info(jsonObject);
console.info('Do the POST call');


var reqPost = https.request(optionsPost, function(res) {
    console.log("statusCode: ", res.statusCode);
    // uncomment it for header details
//  console.log("headers: ", res.headers);


     res.on('data', function(d) {
        console.info('POST result:\n');
        process.stdout.write(d);
        resp.contentType('application/json');
        resp.send(d);
        console.info('\n\nCall completed');
    }); 


});
reqPost.end();
reqPost.on('error', function(e) {
    console.error(e);
});
};
以下是Jetty中的错误:

Jul 30, 2015 4:18:58 PM com.sun.jersey.spi.container.ContainerResponse mapMappableContainerException
SEVERE: The exception contained within MappableContainerException could not be mapped to a response, re-throwing to the HTTP container
java.io.IOException: java.util.concurrent.TimeoutException: Idle timeout expired: 30001/30000 ms
    at org.eclipse.jetty.util.SharedBlockingCallback$Blocker.block(SharedBlockingCallback.java:234)
    at org.eclipse.jetty.server.HttpInputOverHTTP.blockForContent(HttpInputOverHTTP.java:67)
    at org.eclipse.jetty.server.HttpInput$1.waitForContent(HttpInput.java:500)
有人能帮我解决这个问题吗?
感谢您没有发送任何响应内容,Jetty一直在等待数据,直到出现超时

要发送数据调用,请在
reqPost.end()之前写入(…您的数据…)