Signalr | Gradle compatible compiled version of Microsoft Signalr
kandi X-RAY | Signalr Summary
kandi X-RAY | Signalr Summary
Get Up and running with Signalr Java SDK for Android. This is a compiled version of the Android Signar library from the official Repository.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Called when the activity is saved
Signalr Key Features
Signalr Examples and Code Snippets
Community Discussions
Trending Discussions on Signalr
QUESTION
Hi I am trying to create chat app using xamarin app, .net core api and signalR.
I need to get id of curent user inside of SignalR chatHub.
I tried to get HttpContext by using IHttpContextAccessor but SignalR doesn't support it.
I tried to get HttpContext by Context.GetHttpContext() but it only returns empty Context
(as far as i understand to get current HttpContext with Context.GetHttpContext() project either has to be website or i need to place [Authentication] on my ChatHub )
I am using basic authentication on my project and i don't know how to pass user credentials to SignalR hub
Here is code from Xamarin project ChatViewModel which i use to create
new connection to Signalr hub(connection without authentication part works fine)
I don't know how to get curent users email and password instead of "email@hotmail.com" and "123"
ANSWER
Answered 2021-Jun-14 at 00:14_hubConnection = new HubConnectionBuilder()
//.WithUrl($"{APIService._apiUrl}/chatt")
.WithUrl(con, options=> options.Headers.Add("Authorization",$"Basic{credential}"))
.Build();
QUESTION
I am building a Tizen App (.NET Tizen 4.0
) using .NET Core and Xamarin (https://docs.tizen.org/application/dotnet/).
Everything works perfectly fine, except for one thing. It is impossible to start an SignalR (Microsoft.AspNetCore.SignalR.Client (5.0.7)
) connection to a hub. As soon as I create a new HubConnectionBuilder the following exception gets thrown:
System.IO.FileLoadException: Could not load file or assembly 'System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
The weirdest part about this. This exception changes without me doing anything. If I grab a drink for example, come back and run it again a different assembly is missing. For now I saw either System.Threading.Tasks.Extensions, Version=4.2.0.1
or Microsoft.Extensions.DependencyInjection.Abstractions, Version=5.0.0
missing. To top it off: I do not use either of those packages actively.
So basically, as soon as I remove the following line of code, everything works fine.
...ANSWER
Answered 2021-Jun-11 at 06:24The error might be due to the notorious assembly version mismatch problem on Tizen devices.
Explanation: Tizen 4.0 devices come with the pre-installed System.Threading.Tasks.Extensions.dll
assembly of the version 4.1.1.0, but the latest Microsoft.AspNetCore.SignalR.Client nuget package depends on System.Threading.Tasks.Extensions.dll
of 4.2.1.0. So the app will break because the runtime host always resolves the pre-installed assembly first. (The same app will run without problem on Tizen 5.5 devices because the pre-installed assembly version is 4.3.1.0.) However, I'm not sure why Microsoft.Extensions.DependencyInjection.Abstractions.dll
couldn't be resolved since it's not part of the .NET Core runtime and not pre-installed with Tizen devices.
In short, you may add the following event handler your app's Main() and check if the problem persists.
QUESTION
I'm using SignalR on ASP.NET Core 5 web server for Android device management. I can send messages from device (D2C), and receive messages with String
parameters (C2D). But I can't receive messages with custom object parameters, the handler receives all object members as null. I develop an WPF client and it receives this object well.
I'm following ASP.NET Core SignalR Java client documentation. It explains how to use custom objects in Passing Class information in Java section.
In build.gradle file:
...ANSWER
Answered 2021-Jun-10 at 13:49It seems that in the java client the custom object field names should be in lowercase. So changing the field names solves the problem.
Custom class in Android project:
QUESTION
How can I send events from an external js file to Vue components? i use signalR in external file and i want to get data when come from api runtime but when get data can't send it to vue
this is js file :
...ANSWER
Answered 2021-Jun-09 at 13:49it run when i use eventBus
js file :
QUESTION
I'm currently trying to build an app that involves SignalR's hub connection functionality. Eventually, I want to enable the app to handle real-time chats, but first I want to check if the basic part of SignalR works.
I'm trying to ensure that a toastr that notifies about the hub connection is displayed when a user logs in, but the problem is that the toastr is not displayed. Here are some pieces of my code.
[PresenceHub.cs]
...ANSWER
Answered 2021-Jun-06 at 18:18The issue is that you're using Clients.Others
on the server side. This means send this message to all other connections, not yours. You're either wanting Clients.Caller
if you want to send a message to yourself, or Clients.All
to send a message to all connections.
Additionally, you should move this.hubConnection.on('UserIsOnline', ...)
to be before this.hubConnection.start()
to remove the possible race condition of the server responding before your method is registered on the client side.
QUESTION
I am trying to setup a vue3 app with i18n localization. The localization is supposed to be located in json files. I added i18n via vue add i18n
to my project. The questions asked during installation were all answered with the default value except the one with the legacy support (my answer: no). When i try to use a text from a json file, it will tell me in the console [intlify] Not found 'message' key in 'en' locale messages.
The local translations work just fine.
And i have no clue why it is not working with the translations provided in the JSON file.
Here is my code:
packages.json
...ANSWER
Answered 2021-Jun-08 at 15:27The main probles is that the function in i18n.ts doing loadLocalMessages is not getting properly the files from the locales folder.
QUESTION
I have data and I want to present it to a user without him needing to refresh the page. I am using Asp .net core SignalR like this:
...ANSWER
Answered 2021-Jun-08 at 12:17This is not the recommended way to do this. The documentation explicitly says 'Hubs are transient' and 'Don't store state in a property on the hub class. Every hub method call is executed on a new hub instance.' So what you are trying to do, cannot be achieved this way.
What I would suggest you to do instead (no code provided, just some thoughts on architecture):
- Add a Hosted Service
- You can pass an
IServiceProvider
to the service constructor - Let the service control a timer; when the timer elapses, you can use the service provider to create an
IServiceScope
and request an instance ofIHubContext
(see documentation) - Use that context to send updated data to connected clients
QUESTION
I am trying to implement SignalR in a Dotnet Core + ReachtJS web application. While calling the API and making a SignalR connection, I am facing a CORS issue.
ReactJS SignalR Connection Code:
...ANSWER
Answered 2021-Jun-07 at 17:11You have a couple options.
a. Configure all origins that you want to allow via WithOrigins
b. Set withCredentials
to false on the javascript client https://docs.microsoft.com/aspnet/core/signalr/configuration?view=aspnetcore-5.0&tabs=javascript#configure-additional-options
QUESTION
I would like to ensure that a Blazor Server app is secure against cross-origin attacks, in particular against the SignalR hub that Blazor Server is using. The app in question has no need to enable any cross-origin connections as far as I am aware.
Microsoft have a Blazor Server Threat Mitigation document, that states the need for Cross-origin protection (see here: Threat Mitigation). This document suggests that "opening a malicious WebSocket is also possible" and that
- Blazor Server apps can be accessed cross-origin unless additional measures are taken to prevent it. To disable cross-origin access, either disable CORS in the endpoint by adding the CORS middleware to the pipeline and adding the DisableCorsAttribute to the Blazor endpoint metadata or limit the set of allowed origins by configuring SignalR for cross-origin resource sharing.
- If CORS is enabled, extra steps might be required to protect the app depending on the CORS configuration. If CORS is globally enabled, CORS can be disabled for the Blazor Server hub by adding the DisableCorsAttribute metadata to the endpoint metadata after calling MapBlazorHub on the endpoint route builder.
If I understand the above correctly, I need to "disable CORS in the endpoint by adding the CORS middleware to the pipeline and adding the DisableCorsAttribute to the Blazor endpoint metadata", but so far I have been unable to figure out how to do this. [Edit: I think my answer covers this part of the question.]
The above article also references another on SignalR security (see here: Security considerations in ASP.NET Core SignalR) which says that "The protections provided by CORS don't apply to WebSockets. For origin restriction on WebSockets, read WebSockets origin restriction".
The article on WebSockets origin restriction describes how to configure cross origin protection for WebSockets, however this is not explained in the context of configuring the WebSockets used by Blazor Server and I am yet to figure out how to do this.
How do I ensure that my Blazor Server application is secure against cross origin requests to the SignalR hub via its WebSocket(s) or any other relevant connection mechanism(s)?
...ANSWER
Answered 2021-Jun-07 at 09:35I think I have arrived at a solution. I'm not entirely happy with it, but it seems to do the job. This solution is in three parts:
- Apply the DisableCorsAttribute to the Blazor endpoint as recommended in the docs.
- Block cross-origin requests to the Blazor WebSockets endpoint.
- Apply authorization to the Blazor endpoint (strictly speaking this has nothing to do with cross origin requests, but I thought it worth a mention here).
In Startup.ConfigureServices()
add services.AddCors();
- I don't think I need to add a policy here, as I don't actually want to enable cors for any origins other than my own site.
In Startup.Configure()
add app.UseCors();
somewhere after app.UseRouting();
but before app.UseEndpoints();
Use WithMetadata()
to add DisableCorsAttribute
to the Blazor endpoint metadata:
QUESTION
This Microsoft Docs article shows how to configure SignalR in a Blazor app. There's a step there that adds the response compression middleware for the application/octet-stream
MIME type:
ANSWER
Answered 2021-Jun-07 at 08:03Could someone explain if and why this step is required? Does it make any significant difference? I suppose it is to optimize the transmission of binary messages over the SignalR connection.
The Response Compression Middleware is not required when using asp.net core SignalR in the Blazor. In this tutorial, if you remove the services.AddResponseCompression()
and app.UseResponseCompression();
in the Startup.cs file, the SignalR still works well.
More detail information, you could check the Response Compression Middleware, it is used to dynamically compress response bodies and reduce bandwidth utilization.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Signalr
You can use Signalr like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the Signalr component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page