在浏览器中调试HTML5服务器发送的事件 [英] Debugging HTML5 Server-Sent Events in-browser

查看:66
本文介绍了在浏览器中调试HTML5服务器发送的事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Chrome中,是否可以通过任何方式查看/调试服务器发送的事件 Firefox)?我希望它们会出现在Chrome开发者工具的网络标签中。我所知道的最接近的方法是下拉到Wireshark,但这在比较中是相当麻烦的。

Is there any way of viewing/debugging Server-Sent Events in Chrome (or perhaps Firefox)? I was hoping they'd appear in the Network tab of Chrome's developer tools. The closest way I know of is to drop down to Wireshark, but this is fairly cumbersome in comparison.

例如,转到 http://www.emojitracker.com/ 。您会看到页面使用服务器中的数据实时更新,但网络标签中没有任何活动。 (它在/application.js的第97行订阅服务器事件。)

For example, go to http://www.emojitracker.com/. You'll see the page updating in real time with data from the server, but no activity appears in the network tab. (It subscribes to server events on line 97 of /application.js.)

推荐答案

访问 chrome: // cache ,然后单击服务器发送的事件的URL。然后,您将被重定向到 chrome:// view-http-cache / http://emojitrack-gostreamer.herokuapp.com/subscribe/eps 之类的页面,以下:

Visit chrome://cache and click on the URL of the server-sent event. Then you will be redirected to a page like chrome://view-http-cache/http://emojitrack-gostreamer.herokuapp.com/subscribe/eps which contains the following:

http://emojitrack-gostreamer.herokuapp.com/subscribe/eps
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Cache-Control: no-cache
Content-Type: text/event-stream; charset=utf-8
Server: emojitrack-gostreamer
Date: Sun, 21 Sep 2014 11:17:48 GMT
Via: 1.1 vegur
00000000: fc 00 00 00 03 00 04 00 fd 79 7d c4 27 62 2e 00  .........y}.'b..
00000010: 0c 87 7f c4 27 62 2e 00 c8 00 00 00 48 54 54 50  ....'b......HTTP
00000020: 2f 31 2e 31 20 32 30 30 20 4f 4b 00 41 63 63 65  /1.1 200 OK.Acce
00000030: 73 73 2d 43 6f 6e 74 72 6f 6c 2d 41 6c 6c 6f 77  ss-Control-Allow
00000040: 2d 4f 72 69 67 69 6e 3a 20 2a 00 43 61 63 68 65  -Origin: *.Cache
00000050: 2d 43 6f 6e 74 72 6f 6c 3a 20 6e 6f 2d 63 61 63  -Control: no-cac
00000060: 68 65 00 43 6f 6e 74 65 6e 74 2d 54 79 70 65 3a  he.Content-Type:
00000070: 20 74 65 78 74 2f 65 76 65 6e 74 2d 73 74 72 65   text/event-stre
00000080: 61 6d 3b 20 63 68 61 72 73 65 74 3d 75 74 66 2d  am; charset=utf-
00000090: 38 00 53 65 72 76 65 72 3a 20 65 6d 6f 6a 69 74  8.Server: emojit
000000a0: 72 61 63 6b 2d 67 6f 73 74 72 65 61 6d 65 72 00  rack-gostreamer.
000000b0: 44 61 74 65 3a 20 53 75 6e 2c 20 32 31 20 53 65  Date: Sun, 21 Se
000000c0: 70 20 32 30 31 34 20 31 31 3a 31 37 3a 34 38 20  p 2014 11:17:48 
000000d0: 47 4d 54 00 56 69 61 3a 20 31 2e 31 20 76 65 67  GMT.Via: 1.1 veg
000000e0: 75 72 00 00 0d 00 00 00 35 30 2e 31 37 2e 32 34  ur......50.17.24
000000f0: 35 2e 32 31 33 00 00 00 50 00 00 00 01 00 00 00  5.213...P.......

00000000: 64 61 74 61 3a 7b 22 31 46 34 34 45 22 3a 31 2c  data:{"1F44E":1,
00000010: 22 31 46 34 36 44 22 3a 31 7d 0a 0a 64 61 74 61  "1F46D":1}..data
00000020: 3a 7b 22 31 46 34 41 39 22 3a 31 2c 22 31 46 36  :{"1F4A9":1,"1F6
00000030: 31 32 22 3a 31 7d 0a 0a 64 61 74 61 3a 7b 22 31  12":1}..data:{"1
00000040: 46 34 39 36 22 3a 31 7d 0a 0a 64 61 74 61 3a 7b  F496":1}..data:{
00000050: 22 31 46 36 31 44 22 3a 31 7d 0a 0a 64 61 74 61  "1F61D":1}..data
00000060: 3a 7b 22 31 46 33 35 35 22 3a 31 2c 22 31 46 36  :{"1F355":1,"1F6
00000070: 31 44 22 3a 31 2c 22 31 46 36 33 34 22 3a 31 7d  1D":1,"1F634":1}
00000080: 0a 0a 64 61 74 61 3a 7b 22 31 46 33 33 39 22 3a  ..data:{"1F339":

按F5刷新视图。 (如果关闭了请求标签,则该项目将从缓存中逐出,并且您会看到 没有匹配的缓存条目,用于:http://emojitrack-gostreamer.herokuapp.com/subscribe/eps)。

Press F5 to refresh the view. (If the requesting tab is closed the item is evicted from the cache and you'll see "no matching cache entry for: http://emojitrack-gostreamer.herokuapp.com/subscribe/eps").

这篇关于在浏览器中调试HTML5服务器发送的事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆