{"action":"opened","issue":{"url":"https://api.github.com/repos/slact/nchan/issues/234","repository_url":"https://api.github.com/repos/slact/nchan","labels_url":"https://api.github.com/repos/slact/nchan/issues/234/labels{/name}","comments_url":"https://api.github.com/repos/slact/nchan/issues/234/comments","events_url":"https://api.github.com/repos/slact/nchan/issues/234/events","html_url":"https://github.com/slact/nchan/issues/234","id":172768423,"number":234,"title":"[bug] nchan_message_timeout deletes channel","user":{"login":"bymaximus","id":595991,"avatar_url":"https://avatars.githubusercontent.com/u/595991?v=3","gravatar_id":"","url":"https://api.github.com/users/bymaximus","html_url":"https://github.com/bymaximus","followers_url":"https://api.github.com/users/bymaximus/followers","following_url":"https://api.github.com/users/bymaximus/following{/other_user}","gists_url":"https://api.github.com/users/bymaximus/gists{/gist_id}","starred_url":"https://api.github.com/users/bymaximus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bymaximus/subscriptions","organizations_url":"https://api.github.com/users/bymaximus/orgs","repos_url":"https://api.github.com/users/bymaximus/repos","events_url":"https://api.github.com/users/bymaximus/events{/privacy}","received_events_url":"https://api.github.com/users/bymaximus/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-08-23T18:13:02Z","updated_at":"2016-08-23T18:13:02Z","closed_at":null,"body":"Seems when using ```nchan_message_timeout``` with redis storage nchan sets channel TTL after posting fritst message which makes entire channel get removed from redis making nchan unable to know if any subscriber (websocket) is still connected to channel.\r\n\r\nHow to reproduce:\r\n1. make a GET call to post endpoint, it will show 404\r\n2. start websocket subscriber connection, it will create channel\r\n3. make step 1 GET again, it will show channel status, 1 subscriber, 0 messages\r\n4. make a POST call to post endpoint, it will show POST result\r\n5. wait ```nchan_message_timeout``` time and then make step 1 GET again, it will show 404 while still subscriber connected, should show channel status (not expire channel, or expire channel using ```nchan_redis_idle_channel_cache_timeout```\r\n\r\n```\r\n        nchan_redis_url redis://XXXX/0;\r\n        nchan_use_redis on;\r\n        nchan_subscriber_first_message newest;\r\n        nchan_store_messages off;\r\n        nchan_message_timeout 5s;\r\n        #nchan_redis_idle_channel_cache_timeout 5s;\r\n        nchan_redis_idle_channel_cache_timeout 0s;\r\n        nchan_redis_ping_interval 30s;\r\n        #nchan_channel_timeout 10s;\r\n\r\n        location = /condition {\r\n                if ($request_method = 'GET') {\r\n                        nchan_publisher http;\r\n                        nchan_channel_id \"$arg_channel\";\r\n                }\r\n        }\r\n        location = /post {\r\n                if ($request_method = 'GET') {\r\n                        return 405;\r\n                }\r\n                eval_subrequest_in_memory off;\r\n                eval_buffer_size 4k;\r\n                eval_override_content_type text/plain;\r\n                eval $channelStatus {\r\n                        ..........\r\n                        #get here channel status with GET and decide if will POST or not\r\n                        proxy_pass \"http://localhost/condition?channel=$arg_channel\";\r\n                }\r\n                if ($channelStatus = '') {\r\n                        return 304;\r\n                }\r\n                if ($channelStatus ~ '\"subscribers\": 0,') {\r\n                        return 204;\r\n                }\r\n                if ($channelStatus ~ '\"subscribers\": ([1-9]+),') {\r\n                        nchan_publisher http;\r\n                        nchan_channel_id \"$arg_channel\";\r\n                }\r\n        }\r\n        location ~ /postedData/(\\w+)$ {\r\n                nchan_channel_id \"$1\";\r\n                nchan_subscriber websocket;\r\n        }\r\n```\r\n\r\n```\r\n1471975124.084092 [0 XXXXX:48033] \"EVALSHA\" \"43b51538c85d2d2c7950841680553f1bf7dfafa9\" \"0\" \"/796qj\" \"1471975123\" \"asd\" \"application/x-www-form-urlencoded\" \"\" \"5\" \"0\"\r\n1471975124.084145 [0 lua] \"echo\" \" #######  PUBLISH   ######## \"\r\n1471975124.084164 [0 lua] \"EXISTS\" \"{channel:/796qj}\"\r\n1471975124.084172 [0 lua] \"HGETALL\" \"{channel:/796qj}\"\r\n1471975124.084203 [0 lua] \"EXISTS\" \"{channel:/796qj}:msg:1471975123:0\"\r\n1471975124.084214 [0 lua] \"HSET\" \"{channel:/796qj}\" \"current_message\" \"1471975123:0\"\r\n1471975124.084238 [0 lua] \"HSET\" \"{channel:/796qj}\" \"time\" \"1471975123\"\r\n1471975124.084252 [0 lua] \"HSET\" \"{channel:/796qj}\" \"ttl\" \"5\"\r\n1471975124.084263 [0 lua] \"HSET\" \"{channel:/796qj}\" \"max_stored_messages\" \"0\"\r\n1471975124.084298 [0 lua] \"HMSET\" \"{channel:/796qj}:msg:1471975123:0\" \"unbuffered\" \"1\" \"content_type\" \"application/x-www-form-urlencoded\" \"id\" \"1471975123:0\" \"data\" \"asd\" \"prev_tag\" \"0\" \"time\" \"1471975123\" \"eventsource_event\" \"\" \"prev_time\" \"0\" \"ttl\" \"5\" \"tag\" \"0\"\r\n1471975124.084345 [0 lua] \"EXPIRE\" \"{channel:/796qj}:msg:1471975123:0\" \"5\"\r\nHERE ========> 1471975124.084358 [0 lua] \"EXPIRE\" \"{channel:/796qj}\" \"5\" <========HERE\r\n1471975124.084367 [0 lua] \"EXPIRE\" \"{channel:/796qj}:messages\" \"5\"\r\n1471975124.084376 [0 lua] \"EXPIRE\" \"{channel:/796qj}:subscribers\" \"5\"\r\n1471975124.084435 [0 lua] \"PUBSUB\" \"NUMSUB\" \"{channel:/796qj}:pubsub\"\r\n1471975124.084457 [0 lua] \"PUBLISH\" \"{channel:/796qj}:pubsub\" \"\\x9a\\xacmax_msgs+msg\\x00\\x05\\xceW\\xbc\\x8e\\xd3\\x00\\x00\\x00\\xa3asd\\xd9!application/x-www-form-urlencoded\\xa0\"\r\n1471975124.084485 [0 lua] \"llen\" \"{channel:/796qj}:messages\"\r\n1471975124.253918 [0 XXXX] \"EVALSHA\" \"d995d33aa9707b6e63d2caf68154cb34ce0aa423\" \"0\" \"/796qj\" \"1471975123\" \"0\" \"FILO\"\r\n1471975124.253987 [0 lua] \"echo\" \" #######  GET_MESSAGE ######## \"\r\n```\r\n"}}
{"actor":{"display_login":"bymaximus"}}