当前位置: 动力学知识库 > 问答 > 编程问答 >

CouchDb, Java: HTTP entity may not be null

问题描述:

In my Java application Im trying to connect to couchDb on external server. I see error message connection timed out.

error msg:

SEVERE: Allocate exception for servlet servlets.Chat

java.lang.IllegalArgumentException: **HTTP entity may not be null**

at org.apache.http.util.EntityUtils.toString(EntityUtils.java:200)

at org.apache.http.util.EntityUtils.toString(EntityUtils.java:273)

My CouchDb properties

CouchDbProperties prop = new CouchDbProperties()

.setDbName("lcouchdb")

.setCreateDbIfNotExist(true)

.setHost("chatapp.couchappy.com")

.setPort(80)

.setUsername("[email protected]")

.setPassword("bla blaaa")

.setProtocol("http");

I have tried removing .setPort(80) again my app throws an error

 java.lang.IllegalArgumentException: Port is invalid: 0

网友答案:

5984 is the default port for couchdb, but on Couchappy hosting, to improve security, only https on port 443 is allowed.

Plain http on port 80 or 5984 is potentially not safe and prone to man-in-the-middle attacks, so to fully prevent this, Couchappy staff decided to accept connections only on ssl on port 443.

443 is the default port used by browsers when using https. So this means that Couchappy users can hosts on it any kind of data, even a website and let their visitors and google index bots to access it to the url https://thedomainyouwant.couchappy.com instead of the ugly http://thedomainyouwant.couchappy.com:5984

Please note that, if you use some kind of java library, or something like that, you should explicitly set protocol "https" and port "443" instead of 5984.

Thanks for your questions, we are going to prepare a FAQ page on Couchappy website too.

网友答案:

Well it times out because the server is not responding, not a code issue

curl -v http://chatapp.couchappy.com:5984/
* Adding handle: conn: 0x7f88c2804000
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7f88c2804000) send_pipe: 1, recv_pipe: 0
* About to connect() to chatapp.couchappy.com port 5984 (#0)
*   Trying 62.149.192.34...
网友答案:

in my case i got status code 204 with no entity after reading the server api docs again i found out 204 is actually sign that the server received the info and everything is ok.

cheers

分享给朋友:
您可能感兴趣的文章:
随机阅读: