On Mon, 11 Nov 2013 12:59:19 +0100, Sönke Ludwig wrote:

It seems like the MongoDB server doesn't send one of the expected fields
for the getLastError query. If you could enable verbose logging in
your MongoDB server and see what exactly it sends in response to the
last getLastError request, that would be great. I can then adjust the
code appropriately.

Ok, I had a quick and dirty fight with my mongodb instance and was not able to properly configure the verbosity. Or rather I was, but not to a point to debug my problem. So I instead launched Wireshark and captured the reply. Following is the dissected packet. On first glance it seems that mongo does not recognize getLastError command.

Btw, my mongo instance is a default debian instalation:
$ mongod --version
db version v1.4.4, pdfile version 4.5
Mon Nov 11 20:04:40 git version: nogitversion

Thanks,
Drasha

Frame 9: 179 bytes on wire (1432 bits), 179 bytes captured (1432 bits)
Ethernet II, Src: 00:00:00_00:00:00 (00:00:00:00:00:00), Dst: 00:00:00_00:00:00 (00:00:00:00:00:00)
Internet Protocol Version 4, Src: 127.0.0.1 (127.0.0.1), Dst: 127.0.0.1 (127.0.0.1)
Transmission Control Protocol, Src Port: 27017 (27017), Dst Port: 39548 (39548), Seq: 37, Ack: 239, Len: 113
Mongo Wire Protocol
    Message Length: 113
    Request ID: 0x223c71d6 (574386646)
    Response To: 0x00000009 (9)
    OpCode: Reply (1)
    Reply Flags
        .... .... .... .... .... .... .... ...0 = Cursor Not Found: No
        .... .... .... .... .... .... .... ..0. = Query Failure: No
        .... .... .... .... .... .... .... .0.. = Shared Config Stale: No
        .... .... .... .... .... .... .... 0... = Await Capable: No
    Cursor ID: 0
    Starting From: 0
    Number Returned: 1
    Document
        Document length: 77
        Elements
            Element: errmsg
                Type: String (0x02)
                Length: 12
                Value: no such cmd
            Element: bad cmd
                Type: Document (0x03)
                Document
                    Document length: 27
                    Elements
                        Element: getLastError
                            Type: Double (0x01)
                            Value: 1
            Element: ok
                Type: Double (0x01)
                Value: 0