En Thu, 10 Jul 2008 18:10:46 -0300, Guy Davidson <[EMAIL PROTECTED]> escribi�:

On Jul 10, 12:38 pm, samwyse <[EMAIL PROTECTED]> wrote:
On Jul 10, 1:50 pm, Guy Davidson <[EMAIL PROTECTED]> wrote:

> My code (attached below) us supposed to read an HTTP Post message
> coming from a power meter, parse it, and return a proper HTTP 200 Ok
> message. The problem is that the socket fails to send the entire
> message as one message, creating a fragmented message which the power
> meter then fails to read and accept.

From your description, I get the feeling that your power meter has a
broken network stack, and you're trying to program around it.  You
need to repair the meter.

The meter sends HTTP Post messages, and expects, as a reply, an HTTP
200/Ok message.

I try to send the following message, using the socket.send() command:

'HTTP/1.1 200 OK\r\nDate: Thu, 10 July 2008 14:07:50 GMT\r\nServer:
Apache/2.2.8 (Fedora)\r\nX-Powered-By: PHP/5.2.4\r\nContent-Length: 4\r
\nConnection: close\r\nContent-Type: text/html; charset=UTF-8\r\n\r
\n[0]\n'

However, when I snoop on the packets in wireshark, here's what I see:

HTTP/1.1 200 Ok:

HTTP/1.1 200 OK
Date: Wed, 09 July 2008 14:55:50 GMT
Server: Apache/2.2.8 (Fedora)
X-Powered-By:

Continuation or non-HTTP traffic:

PHP/5.2.4
Content-Length: 4
Connection: close
Content-Type: text/html; charset=UTF-8

[0]

It splits into two packages, which the meter can't read, and the
communication breaks down there.

Any ideas?

As Guy Davidson has already pointed out, this is a problem in the meter TCP implementation, and you should ask the vendor to fix it. (Anyway, looks like "somewhere" there is a buffer size of 100 bytes or so, very small).

As a workaround, try to shorten your HTTP response; I guess the Server and X-Powered-By headers are not required; the Date probably isn't either; and if all your responses are like "[0]" a simple "Content-Type: text/plain" may suffice (the meter might just ignore it, anyway).

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to