Closed mynote closed 10 years ago
Hi @mynote
I suppose that when the device goes off and come back your application is losing the last values it receives for LastModify and Etag variables. Try to persist it or, if they are empty, set an big old value for the "If-Modified-Since", like 01/01/1970. And with your configuration, only the last 10 messages published on the last 2 hours will be available. So, if the device goes off for 3 hours, and no messages were published on the last 2 hours, when it come back, it will not receive old messages.
Thank you. But ive stored it as SharedPreference and get it onec the service get recreated. So it's still persistent and it wont loose it's value. I could see that the JS Client uses GET params to get the old value instead of header-values. May this be the issue? the last-modified header uses the following timeformat: Fri, 04 Apr 2014 15:47:16 GMT
Or is this wrong? you write that i should use 01/01/1970 onec there is no value set, yet. Which is the proper format doing this?
The time format is right. The one I sent was just an example to use a very old date. I look again to your configuration and, if you set these two directives
push_stream_last_received_message_time "$arg_time";
push_stream_last_received_message_tag "$arg_tag";
you have to send the values using the time and tag parameter, not the header.
But the original, and default behavior is to send using the header. You can remove these directives and try again? It should works fine.
removed it, but still didnt :-(
location ~ /lp/(.*) { push_stream_channels_path $1; push_stream_subscriber long-polling; push_stream_message_template "{\"id\":~id~,\"channel\":\"~channel~\",\"text\":\"~text~\",\"tag\":\"~tag~\",\"time\":\"~time~\"}"; push_stream_subscriber_connection_ttl 241s; push_stream_longpolling_connection_ttl 241s; }
any other idea?
Request:
http://my.ip/lp/3***03932; LastModify: Sat, 05 Apr 2014 16:03:39 GMT; ETAG: 1
if i send a new push, its receiving it just well but still no old messages.
channel-stats are:
-> channel -->name>3***03932</name --->published_messages>1</published_messages -->stored_messages>1</stored_messages -->subscribers>1</subscribers ->/channel
Check if the code on this issue #97 helps you. Which sequence of events are you doing in your tests? If you start the nginx, send a message and after that connect the subscriber using a time before the minute you sent the message, what happens? Do you receive the published message?
still the same. tried to change it with the code in #97 but queued messages are still not received.
Tried sending 10+ messages to the client while the app was not installed. Then ive started the app and used
connection.addRequestProperty("If-Modified-Since", readString("mLastModify", "01/01/1970")); connection.addRequestProperty("If-None-Match", readString("mEtag", "")); connection.setRequestProperty("Connection", "Keep-Alive"); connection.setRequestProperty("Content-Type", "application/json"); connection.setRequestProperty("Charset", "UTF-8"); connection.setRequestProperty("Content-Transfer-Encoding", "binary"); connection.connect();
/\ some more code **/ rd = new BufferedReader(new InputStreamReader(connection.getInputStream())); sb = new StringBuilder(); while ((line = rd.readLine()) != null) { sb.append(line); } new MessageProcessor(sb.toString());
Log.i("", "RestPushServiceRunnable: " + ": Response Code: " + resCode + "; Keep Alive: " + (end_time - begin_time) / 1000 + "(s)" + "Last-Modified" + connection.getHeaderField("Last-Modified"));
writeString("mLastModify", connection.getHeaderField("Last-Modified")); writeString("mEtag", connection.getHeaderField("Etag"));
tried setRequestProperty aswell instead of addRequestProperty but didnt change anything.
location ~ /lp/(.*) { push_stream_channels_path $1; push_stream_subscriber long-polling; push_stream_authorized_channels_only off;
push_stream_subscriber_connection_ttl 600s;
push_stream_longpolling_connection_ttl 600s;
}
tried removing the push_stream_template but didnt change anything.
Any other idea?
/\ edit **/ setDoOutput causes to use POST instead of GET.
You set the default date in the wrong format. It should be "Thu, 01 Jan 1970 00:00:00 UTC". The "01/01/1970" was just an example of an old date, not about the format. I'm sure that the problem is on your code or on your configuration, because the module has a lot of tests about getting old messages. If you want to, send me your hole code and configuration to check where the problem is.
Hello,
im using Android to have a "push-system".
Well, its working fine, but old messages dont get submitted, even when there are some.
NGinx configuration:
location ~ /lp/(.*) { push_stream_channels_path $1; push_stream_subscriber long-polling; push_stream_last_received_message_time "$arg_time"; push_stream_last_received_message_tag "$arg_tag"; push_stream_message_template "{\"id\":~id~,\"channel\":\"~channel~\",\"text\":\"~text~\",\"tag\":\"~tag~\",\"time\":\"~time~\"}"; push_stream_subscriber_connection_ttl 241s; push_stream_longpolling_connection_ttl 241s; }
location /pub { push_stream_publisher admin; push_store_messages on; push_stream_channels_path $arg_id; push_stream_store_messages on; push_message_timeout 2h; push_max_message_buffer_length 10; }
android:
connection = openUrl(new URL("http://my.ip/lp/);
connection.setConnectTimeout(3 * 60 * 1000);
connection.setReadTimeout(4 * 60 * 1000);
connection.addRequestProperty("If-Modified-Since", LastModify);
connection.addRequestProperty("If-None-Match", Etag);
connection.setRequestProperty("Connection", "Keep-Alive");
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("Charset", "UTF-8");
connection.setRequestProperty("Content-Transfer-Encoding", "binary");
connection.setRequestMethod("GET");
connection.setDoInput(true);
Request looks like that: --> http://my.ip/lp/35424*****932; Headers --> LastModify: Fri, 04 Apr 2014 12:52:55 GMT; ETAG: 1
while (true) { .... LastModify = getHeaderField("Last-Modified"); Etag = getHeaderField("Etag"); }
it works aslong as the device is connected. onec it goes off and pushs sent, the device come back and dont get the queue.
What may cause the problem?