-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: WebView2 WebResourceRequested does not fired for WebSockets #4303
Comments
@yildirimcagri-msft Any update about this? |
Thanks for reporting this, we added this to our backlog. This might take a while to test as we currently don't have a WebSocket backend to test this scenario for. For more information, I have some questions for you:
|
I would like to add my case here that creating an instance of WebSocket did not send any messages to the socker server. |
Hi @yildirimcagri-msft , Thank you for your response. Regarding your questions:
Regards |
Hi @yildirimcagri-msft , I tried suggested workaround but without success. At first I used events DevToolsProtocolHelper.Fetch.RequestPaused and DevToolsProtocolHelper.Network.RequestWillBeSent. But non of them is fired for web sockets. Then I tried Network.WebSocketCreated, but there is no access to Request. Network.WebSocketWillSendHandshakeRequest has access to request. Class Network.Headers is "empty" with no properties or methods. And the documentation is really poor. I faced to this issue that is still open #2488. I tried workaround from last post but it doesn't work in this event. I'm able to read the headers but I haven't found a way, how to set them. Despite documentation this seems to be fired after the request is sent. At first I see request in Chrome Dev tools and then breakpoint in code is hit. I wanted also try method Network.SetExtraHTTPHeadersAsync(). I was able to add "extra" header but it was again present only in non-web socket requests. |
What happened?
Hi,
I'm using WebView2 in custom WFP application. I need to add custom headers into requests so I use WebResourceRquested event. Here is my code:
`using Microsoft.Web.WebView2.Core;
using Microsoft.Web.WebView2.Wpf;
namespace WebViewAddingHeaders;
internal class MyWebBrowser: WebView2
{
public MyWebBrowser()
{
CoreWebView2InitializationCompleted += OnInitializationCompleted;
}
}`
But I noticed that this event is not fired for web sockets. I try to access python + streamlit application. There are sent multiple requests. For "normal" requests the header is present.
![image](https://private-user-images.githubusercontent.com/156662733/296770537-3e57e00b-4762-4d09-b004-606bfb920d9c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIj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GczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxN1QxNDIzNThaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0wODJhOTAxMjA1M2FhNzdjNGM2ODc0NTlhNTUzYWI5YjUwMzE0MjVlOTY1NzY1MDZkZWUwNmJhMTA4MzNhNTM0JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.QTphpEOd-TLCmT1g-NyfhQv0V2B3PxTdJyx8Z__25-Y)
But it is not present for web sockets
I tried to filter only WebSockets in AddWebResourceRequestedFilter. I tried to enable custom scheme for ws. But nothing helped.
Is it possible to catch and enhance all requests, including web sockets?
Importance
Important. My app's user experience is significantly compromised.
Runtime Channel
Stable release (WebView2 Runtime)
Runtime Version
1.0.2210.55
SDK Version
No response
Framework
WPF
Operating System
Windows 11
OS Version
No response
Repro steps
In description.
Repros in Edge Browser
No
Regression
No, this never worked
Last working version (if regression)
No response
AB#48649859
The text was updated successfully, but these errors were encountered: