Net maui cannot get information from WebSocket api #2629
Labels
dotnet-maui/subsvc
dotnet-mobile/svc
Pri2
support-request
Support-style question;customer needs help solving a problem [org]
Type of issue
Other (describe below)
Description
I have a WebSocket application that I used in C# console before. I had no problems with it working in console, but I want to convert it to a multimedia project with netmau. Android emulator does not work on my computer. That's why I do my tests in Windows emulator.
When I check with brekboint in the code I shared below, it gets stuck when it reaches WebSocketReceiveResult result = await webSocket.ReceiveAsync(new ArraySegment(buffer), CancellationToken.None); I can't get any response. I don't know if I'm starting the application incorrectly or if there's a part I need to add.
My codes are as follows, I would be glad if you could guide me :(
`using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.WebSockets;
using System.Text;
using System.Threading.Tasks;
namespace MauiApp1.Model
{
public static class WebSocket
{
public static string checker = Ayarlar.ComputeSha256Hash(Ayarlar.APIKEY + Ayarlar.hostname + "/ws");
public static ClientWebSocket webSocket = new ClientWebSocket();
public static DateTime senddate = DateTime.Now;
public static async Task ConnectToWebsocket()
{
try
{
webSocket.Options.SetRequestHeader("APIKEY", Ayarlar.APIKEY);
webSocket.Options.SetRequestHeader("Authorization", Ayarlar.HASH);
webSocket.Options.SetRequestHeader("Checker", checker);
await webSocket.ConnectAsync(new Uri(Ayarlar.websocketurl), CancellationToken.None);
}`
The code I use to start the code is as follows
` public MainPage()
{
InitializeComponent();
WebSocket.ConnectToWebsocket();
}`
I would be very glad if you could support me on this subject. Thank you in advance
Page URL
https://learn.microsoft.com/tr-tr/dotnet/maui/whats-new/dotnet-8?view=net-maui-8.0
Content source URL
https://github.com/dotnet/docs-maui/blob/main/docs/whats-new/dotnet-8.md
Document Version Independent Id
1abc248e-68ab-afa8-4b3d-7fc5e77f255b
Article author
@davidbritch
Metadata
Related Issues
The text was updated successfully, but these errors were encountered: