WebSocket connections are listed with the "http:" protocol in the netmonitor/console
Categories
(DevTools :: Console, defect, P3)
Tracking
(firefox73 fixed)
| Tracking | Status | |
|---|---|---|
| firefox73 | --- | fixed |
People
(Reporter: espadrine, Assigned: thiago.arrais)
References
(Regressed 1 open bug)
Details
(Keywords: good-first-bug)
Attachments
(1 file)
No description provided.
| Reporter | ||
Comment 1•9 years ago
|
||
Obviously, Websocket connections should be listed as "ws://…" (or "wss://" for secured connections). However, they are listed as "http://localhost/$socket.io/1/websocket/15713794881205045864", for instance.
Updated•8 years ago
|
Comment 2•8 years ago
|
||
Check if the protocol is still actually shown (it my not be).
Updated•8 years ago
|
Updated•3 years ago
|
Comment 3•2 years ago
|
||
Honza, it still happens in netmonitor and console. Do you think it could be a good first bug?
Comment 4•2 years ago
|
||
Andrea, the request displaying in the list is the original HTTP upgrade request (coming from nsIHttpChannel.URL.spec).
How can we get URL of the actual WS connection?
Honza
Comment 5•2 years ago
|
||
STR:
- Go to http://janodvarko.cz/test/websockets/
- Open netmonitor
- Click on the
Connectbutton
Comment 6•2 years ago
|
||
Valentin, do you know how to obtain a nsIWebSocketChannel from a nsIHttpChannel?
Comment 7•2 years ago
|
||
(In reply to Andrea Marchesini [:baku] from comment #6)
Valentin, do you know how to obtain a nsIWebSocketChannel from a nsIHttpChannel?
I presume this is in the parent process.
The WSChannel sets itself as the notification callbacks so I suppose a simple NS_QueryNotificationCallbacks should suffice.
Comment 8•2 years ago
|
||
Valentin: I tried the following:
diff --git a/devtools/server/actors/network-monitor/network-observer.js b/devtools/server/actors/network-monitor/network--- a/devtools/server/actors/network-monitor/network-observer.js
+++ b/devtools/server/actors/network-monitor/network-observer.js
@@ -660,16 +660,23 @@ NetworkObserver.prototype = {
if (channel.loadInfo) {
causeType = channel.loadInfo.externalContentPolicyType;
const { loadingPrincipal } = channel.loadInfo;
if (loadingPrincipal && loadingPrincipal.URI) {
causeUri = loadingPrincipal.URI.spec;
}
}
+ if (channel.notificationCallbacks) {
+ let wsChannel = channel.notificationCallbacks.QueryInterface(Ci.nsIWebSocketChannel);
+ if (wsChannel) {
+ event.url = wsChannel.URI.spec;
+ }
+ }
+
event.cause = {
type: causeTypeToString(causeType),
loadingDocumentUri: causeUri,
stacktrace,
};
httpActivity.isXHR = event.isXHR =
causeType === Ci.nsIContentPolicy.TYPE_XMLHTTPREQUEST ||
But, I am seeing an exception when connecting to WS:
TypeError: "channel.notificationCallbacks.QueryInterface is not a function"
What am I doing wrong?
Honza
Comment 9•2 years ago
|
||
notificationCallbacks is a nsIInterfaceRequestor. You should call getInterface on it, not QueryInterface.
Comment 10•2 years ago
|
||
I tried the following:
diff --git a/devtools/server/actors/network-monitor/network-observer.js b/devtools/server/actors/network-monitor/network--- a/devtools/server/actors/network-monitor/network-observer.js
+++ b/devtools/server/actors/network-monitor/network-observer.js
@@ -666,16 +666,23 @@ NetworkObserver.prototype = {
if (channel.loadInfo) {
causeType = channel.loadInfo.externalContentPolicyType;
const { loadingPrincipal } = channel.loadInfo;
if (loadingPrincipal && loadingPrincipal.URI) {
causeUri = loadingPrincipal.URI.spec;
}
}
+ if (channel.notificationCallbacks) {
+ let wsChannel = channel.notificationCallbacks.getInterface(Ci.nsIWebSocketChannel);
+ if (wsChannel) {
+ event.url = wsChannel.URI.spec;
+ }
+ }
+
event.cause = {
type: causeTypeToString(causeType),
loadingDocumentUri: causeUri,
stacktrace,
};
httpActivity.isXHR = event.isXHR =
causeType === Ci.nsIContentPolicy.TYPE_XMLHTTPREQUEST ||
But, I am still seeing an error:
Exception { name: "NS_NOINTERFACE", message: "Component returned failure code: 0x80004002 (NS_NOINTERFACE) [nsIInterfaceRequestor.getInterface]", result: 2147500034, filename: "resource://devtools/server/actors/network-monitor/network-observer.js", lineNumber: 678, columnNumber: 0, data: null, stack: "_createNetworkEvent@resource://devtools/server/actors/network-monitor/network-observer.js:678:53\n_onRequestHeader@resource://devtools/server/actors/network-monitor/network-observer.js:764:10\nNetworkObserver.prototype.observeActivity<@resource://devtools/server/actors/network-monitor/network-observer.js:577:12\nexports.makeInfallible/<@resource://devtools/shared/ThreadSafeDevToolsUtils.js:111:22\n", location: XPCWrappedNative_NoHelper }
ThreadSafeDevToolsUtils.js:90:13
Comment 11•2 years ago
|
||
(In reply to Jan Honza Odvarko [:Honza] (always need-info? me) from comment #10)
Hi Honza,
I got some code that seems to work on the page in comment 5.
diff --git a/devtools/server/actors/network-monitor/network-observer.js b/devtools/server/actors/network-monitor/network-observer.js
--- a/devtools/server/actors/network-monitor/network-observer.js
+++ b/devtools/server/actors/network-monitor/network-observer.js
@@ -664,6 +664,15 @@ NetworkObserver.prototype = {
causeUri = loadingPrincipal.URI.spec;
}
}
+ if (channel.notificationCallbacks) {
+ let wsChannel = null;
+ try {
+ wsChannel = channel.notificationCallbacks.QueryInterface(Ci.nsIWebSocketChannel);
+ } catch(e) {}
+ if (wsChannel) {
+ event.url = wsChannel.URI.spec;
+ }
+ }
event.cause = {
type: causeTypeToString(causeType),
I think we need the try catch bit because not all channels can be QId to nsIWebSocketChannel.
Comment 12•2 years ago
|
||
Thanks Valentin, this works for me!
Honza
Updated•2 years ago
|
Comment 13•2 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=566f28ffdb360308d2a76f53510e310b58f90c28
Comment 14•2 years ago
|
||
Instructions for anyone interested in fixing this bug:
- This is the piece that get the original WS url:
diff --git a/devtools/server/actors/network-monitor/network-observer.js b/devtools/server/actors/network-monitor/network-observer.js
--- a/devtools/server/actors/network-monitor/network-observer.js
+++ b/devtools/server/actors/network-monitor/network-observer.js
@@ -666,16 +666,31 @@ NetworkObserver.prototype = {
if (channel.loadInfo) {
causeType = channel.loadInfo.externalContentPolicyType;
const { loadingPrincipal } = channel.loadInfo;
if (loadingPrincipal && loadingPrincipal.URI) {
causeUri = loadingPrincipal.URI.spec;
}
}
+ // Show the right WebSocket URL in case of WS channel.
+ if (channel.notificationCallbacks) {
+ let wsChannel = null;
+ try {
+ wsChannel = channel.notificationCallbacks.QueryInterface(
+ Ci.nsIWebSocketChannel
+ );
+ } catch (e) {
+ // Not all channels implement nsIWebSocketChannel.
+ }
+ if (wsChannel) {
+ event.url = wsChannel.URI.spec;
+ }
+ }
+
event.cause = {
type: causeTypeToString(causeType),
loadingDocumentUri: causeUri,
stacktrace,
};
httpActivity.isXHR = event.isXHR =
causeType === Ci.nsIContentPolicy.TYPE_XMLHTTPREQUEST ||
- We also need to fix couple of test:
- devtools/client/netmonitor/test/browser_net_filter-01.js
- devtools/client/netmonitor/test/browser_net_websocket_stacks.js
It should be about expecting ws and not http in tests.
See here:
- https://searchfox.org/mozilla-central/rev/55aa17110091deef24b913d033ccaf58f9c6d337/devtools/client/netmonitor/test/browser_net_websocket_stacks.js#23
- https://searchfox.org/mozilla-central/rev/55aa17110091deef24b913d033ccaf58f9c6d337/devtools/client/netmonitor/test/browser_net_filter-01.js#198
Note that WS_CONTENT_TYPE_SJS uses http: so, we need another constant based on WS_URL
Honza
| Assignee | ||
Comment 15•2 years ago
|
||
Can I tackle this one?
Comment 16•2 years ago
|
||
Sure Thiago!
You may want to read this in order to set up the work environment: http://docs.firefox-dev.tools/getting-started/
I'm going to assign the bug to you so other people know it's not available anymore.
Feel free to ask any question, either here, or on Slack :)
| Assignee | ||
Comment 17•2 years ago
|
||
| Assignee | ||
Comment 18•2 years ago
|
||
Just opened a review. This is my first contribution to FF, though, and I'm not sure if I did everything right. Please let me know if you need anything else.
Comment 19•2 years ago
|
||
Pushed by jodvarko@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/aa40b800b2ce Fix console protocol for ws connections. r=Honza,nchevobbe
| Assignee | ||
Comment 20•2 years ago
|
||
Not sure what is needed here. I'm running devtools/client/netmonitor/test/browser_net_websocket_stacks.js locally and can't reproduce the regression.
Can anyone point me in the right direction?
Comment 21•2 years ago
|
||
| bugherder | ||
Description
•