views:

32

answers:

1

hi,

I'm using html5 websockets, dev.w3.org/html5/websockets/, and php socket functions, php.net/manual/en/ref.sockets.php. My problem is that messages sent from the client using websockets to the server are being truncated to a maximum of 1449 bytes. When I set net.ipv4.tcp_timestamps to 0, a couple extra bytes are received. I am using socket_recv. I did try to loop over socket_recv, but after the first call to socket_recv, the following warning emits:

Warning: socket_recv(): unable to read from socket [11]: Resource temporarily unavailable in [file] on line 94

Note:

  • When I use socket_recv() with MSG_DONTWAIT, I get the above warning. e.g. socket_recv($socket, $data, 10024, MSG_DONTWAIT)
  • If I just use 0, the system blocks. e.g. socket_recv($socket, $data, 10024, 0)

So, why are messages sent being truncated?

my sysctl.conf:

net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 4294967295
kernel.shmall = 268435456
net.ipv4.tcp_syncookies = 1
net.core.somaxconn = 900
net.ipv4.tcp_fin_timeout = 20
net.core.netdev_max_backlog = 2500


net.core.rmem_default = 262144
net.core.wmem_default = 262144

net.core.rmem_max = 16777216
net.core.wmem_max = 16777216

net.ipv4.udp_rmem_min = 16384
net.ipv4.udp_wmem_min = 16384

net.ipv4.tcp_rmem = 8192 87380 16777216
net.ipv4.tcp_wmem = 8192 65536 16777216

net.ipv4.tcp_mem = 8388608 12582912 16777216
net.ipv4.udp_mem = 8388608 12582912 16777216

net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_sack = 1 
net.ipv4.tcp_window_scaling = 1
A: 

Well, it turns out I had to call socket_select() again after each socket_recv() for a given socket.

adam