为什么AndroidAsync断开时间这么久?

时间:2015-12-18 20:08:25

标签: android websocket androidasync-koush

我正在使用AndroidAsync koush低级网络协议库。我正在使用WebSocket连接到服务器。我能够连接,发送/接收消息和断开连接。我的断开时间很长。服务器平均没有检测到断开连接59秒。

为了重现这个问题,我连接了WebSocket,授权并每隔10秒开始ping一次。然后我打开飞机模式,我的网络连接断开。此时调用setClosedCallback方法。以下是我记录此消息的方式:

gradle.properties

这是让我知道WebSocket已关闭的日志消息:

WebSocket已关闭异常:recvfrom失败:ETIMEDOUT(连接超时)

但是我们的服务器在大约59秒内没有收到断开连接消息。我们的服务器正在使用这些库:

  • GEVENT == 1.0
  • GEVENT-的WebSocket == 0.9.2
  • greenlet == 0.4.2

有没有办法加快我的速度?是否存在套接字级别超时,我可以将其设置为较低的值,以便我的服务器人员能够更快地获得断开连接消息?

1 个答案:

答案 0 :(得分:9)

由于closing handshake未实现RFC 6455所需的this(有关详细信息,请参阅{{3}}),因此您的WebSocket服务器无法检测上下文中的断开 WebSocket 。因此,服务器必须在TCP / IP 的上下文中等待SELECT FLOOR((ROUND((e.min_price) * 1, 2)) / 100) + 1 AS `range`, COUNT(*) AS `count` FROM `mage_catalog_product_index_price` AS `e` INNER JOIN `mage_catalog_category_product_index` AS `cat_index` ON cat_index.product_id=e.entity_id AND cat_index.store_id='1' AND cat_index.visibility IN(2, 4) AND cat_index.category_id = '2' WHERE 1=1 AND (e.entity_id IN('1749', '1750', '1751', '1752', '1753', '1754', '1755', '1756', '1757', '1758', '1759', '1760', '1761', '1762', '1763', '1764', '1765', '1766', '1767', '1768', '1769', '1770', '1771', '1772', '1773', '1774', '1775', '1776', '1777', '1778', '1779', '1780', '1781', '1782', '1783', '1784', '1785', '1786', '1787', '1788', '1789', '1790', '1791', '1792', '1793', '1794', '1795', '1796', '1797', '1798', '1799', '1800', '1801', '1802', '1803', '1804', '1805', '1806', '1807', '1809', '1810', '1811', '1812', '1813', '1814', '1815', '1816', '1817', '1818', '1819', '1820', '1821', '1822', '1824', '1825', '1826', '1827', '1828', '1829', '1830', '1831', '1832', '1833', '1834', '1836', '1837', '1838', '1839', '1840', '1841', '1842', '1843', '1844', '1845', '1846', '1847', '1848', '1849', '1850', '1851', '1852', '1853', '1854', '1855', '1856', '1876', '1877', '1878', '1879', '1880', '1881', '1882', '1892', '1893', '1894', '1895', '1896', '1897', '1898', '1899', '1900', '1901', '1902', '1903', '1904', '1905')) 1=1 AND ( e.website_id = '1' ) AND ( e.customer_group_id = '1') AND (e.min_price IS NOT NULL) GROUP BY FLOOR((ROUND((e.min_price) * 1, 2)) / 100) + 1 ORDER BY FLOOR((ROUND((e.min_price) * 1, 2)) / 100) + 1 ASC 以检测断开连接。

使用符合RFC 6455的WebSocket库并正确实现结束握手。