Websocket, recieve frame without knowing size

Please post support and help requests here.
sirherrbatka
Posts: 7
Joined: 28 May 2015, 08:58

Websocket, recieve frame without knowing size

Postby sirherrbatka » 28 May 2015, 09:30

Hi,

I'm using poco for websocket. The problem is that i can't obtain frames or any size since i need to allocate buffer first. I took a look at the source code of the poco, and from what I have seen size is obtained from the header, and header is obtained with protected method in websocketimpl (so I can't use it) I also can't inject my own websocketimpl. There was also other method, that was supposed to accept fifo buffer but after looking at it I see:

int ret = impl()->receiveBytes(fifoBuf.next(), (int)fifoBuf.available());

Which really does not look like it can obtain any number of bytes.

What should I do?

alex
Posts: 1375
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: Websocket, recieve frame without knowing size

Postby alex » 28 May 2015, 16:08

That capability was added in the development branch and will be in release 1.7.0

sirherrbatka
Posts: 7
Joined: 28 May 2015, 08:58

Re: Websocket, recieve frame without knowing size

Postby sirherrbatka » 01 Jun 2015, 09:06

Oh, ok.

Any idea what is ETA for new version?

johnyk
Posts: 1
Joined: 01 Jul 2016, 16:38

Re: Websocket, recieve frame without knowing size

Postby johnyk » 01 Jul 2016, 16:54

Hi,

I have the same problem. Nowaday in Poco v1.7.3 this method (receiveFrame(Buffer)) is still not available. Was there any problem to include it to 1.7.x release?

I tried solve it with select() + ws.available(). Something like this:

Code: Select all

...
while(!stopped)
{
  readList.clear(); readList.push_back(websocket);
  Poco::Net::Socket::select(readList, writeList, exceptList, Poco::Timespan(0, 300000));

  if(readList.size())
  {
    unsigned int buffer_size = websocket.available();
    char *buffer = new char[buffer_size]();
    websocket.receiveFrame(buffer, buffer_size, flags);
    ...
  }
  ...
  Poco::Thread::sleep(300);
}
...


This works on linux. However on Windows, if frame is larger than 8kB, websocket.available() returns always 8192 bytes, but receiveFrame throws WebSocket Exception: Insufficient buffer for payload size 73264. Is there any difference in behaviour between implementation of available() on windows and on linux?

Is there any other way how to solve this problem? Will method receiveFrame(Buffer) be in next Poco release?

mecsco
Posts: 1
Joined: 04 Sep 2017, 17:38

Re: Websocket, recieve frame without knowing size

Postby mecsco » 04 Sep 2017, 17:42

It looks like this hasn't been pushed to the current 1.7.8p3 release yet either - does that mean it won't be until the next major version, given this thread is now over 2 years old?


Return to “Support”

Who is online

Users browsing this forum: No registered users and 2 guests

cron