2016-06-21 209 views
1

すべて、私は奇妙な問題に遭遇しました。mongodb接続がMongoSocketReadExceptionをスローする

私は3台のMongoDBサーバーを持っていて、それをreplsetに結合しました。 - 1つは1つで、もう1つは2次ノードです。 私のMongoDBクライアントは、Java MongoDBクライアント、Spring環境です。

replsetノードに向けるには、haproxyを使用します。

私はhaproxyに接続したときに時々、モンゴクライアントは次の例外がスローされます:私は再試行すると、それは消え、数分後には再び表示されます

message:Exception found: Prematurely reached end of stream; nested exception is com.mongodb.MongoSocketReadException: Prematurely reached end of stream

を。

haproxy設定は以下を示している:

global 
    daemon 
    user vcap 
    group vcap 
    log /dev/log daemon info 
    maxconn 4096 

defaults 
    log global 
    option dontlognull 
    mode tcp 
    timeout connect 5000ms 
    timeout client 30000ms 
    timeout server 30000ms 
    retries 3 
    option redispatch 

# admin gui 
listen stats 
bind :8080 
mode http 
stats enable 
stats uri /stats 

default-server on-error fastinter error-limit 3 inter 3000ms fastinter 1000ms downinter 300s fall 3 

frontend fe_mongo_27027_tcp 
    bind 0.0.0.0:27027 
    mode tcp 
    option tcplog 
    use_backend be_mongo_27027_tcp 

backend be_mongo_27027_tcp 
    mode tcp 
    option tcp-check 
    # mongodb wire protocol 
    tcp-check send-binary 3a000000 # Message Length (58) 
    tcp-check send-binary EEEEEEEE # Request ID (random value) 
    tcp-check send-binary 00000000 # Response To (nothing) 
    tcp-check send-binary d4070000 # OpCode (Query) 
    tcp-check send-binary 00000000 # Query Flags 
    tcp-check send-binary 61646d696e2e # fullCollectionName (admin.$cmd) 
    tcp-check send-binary 24636d6400 # continued 
    tcp-check send-binary 00000000 # NumToSkip 
    tcp-check send-binary FFFFFFFF # NumToReturn 
    # Start of Document 
    tcp-check send-binary 13000000 # Document Length (19) 
    tcp-check send-binary 10 # Type (Int32) 
    tcp-check send-binary 69736d617374657200 # ismaster: 
    tcp-check send-binary 01000000 # Value : 1 
    tcp-check send-binary 00 # Term 

    tcp-check expect binary 69736d61737465720001 #ismaster True 
    # mongodb check end 

    option tcplog 
    option tcpka 

    server mongodb-10.62.90.175 10.62.90.175:27017 check inter 2000 

    server mongodb-10.62.90.176 10.62.90.176:27017 check inter 2000 

    server mongodb-10.62.90.174 10.62.90.174:27017 check inter 2000 

答えて

0

それはタイムアウト設定が原因で、接続が近いので、Mongoのクライアントは、バイナリを受け取ることができない今、私はタイムアウト設定を削除し、それが動作するようになりました。