<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: MetinAbaszade</title>
    <description>The latest articles on DEV Community by MetinAbaszade (@matinabaszada).</description>
    <link>https://dev.to/matinabaszada</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1044883%2F2d019531-ac67-4efd-a36a-1e52c20bbf9b.jpeg</url>
      <title>DEV Community: MetinAbaszade</title>
      <link>https://dev.to/matinabaszada</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/matinabaszada"/>
    <language>en</language>
    <item>
      <title>How to Manage Persistent Connections in a WhatsApp-like Chat Application Using ASP.NET SignalR and EF Core?</title>
      <dc:creator>MetinAbaszade</dc:creator>
      <pubDate>Tue, 06 Aug 2024 06:50:50 +0000</pubDate>
      <link>https://dev.to/matinabaszada/how-to-manage-persistent-connections-in-a-whatsapp-like-chat-application-using-aspnet-signalr-and-ef-core-1nd8</link>
      <guid>https://dev.to/matinabaszada/how-to-manage-persistent-connections-in-a-whatsapp-like-chat-application-using-aspnet-signalr-and-ef-core-1nd8</guid>
      <description>&lt;p&gt;I'm currently developing a chat application similar to WhatsApp using C#, ASP.NET SignalR, and EF Core. My goal is to implement both group chats and one-to-one chats and store them in a database for persistence. However, I'm encountering an issue with managing user connections.&lt;/p&gt;

&lt;p&gt;Each time a user connects to the SignalR hub, a new ConnectionId is generated. This requires me to re-add the user to their respective groups and one-to-one chats with each refresh. Essentially, every time the user refreshes the page, they leave and then rejoin all their chats.&lt;/p&gt;

&lt;p&gt;Although I can store the ConnectionId in cache or in the database, it becomes useless because SignalR will always generate a new ConnectionId upon reconnection. I doubt that real-world applications handle connections this way, so I’m looking for guidance on how to manage this situation effectively.&lt;/p&gt;

&lt;p&gt;Here are my specific questions:&lt;/p&gt;

&lt;p&gt;How can I persist user connections across page refreshes and disconnections?&lt;br&gt;
Is this issue specific to web applications, or does it also occur in mobile and desktop applications?&lt;br&gt;
What are the best practices for handling user reconnections in SignalR?&lt;br&gt;
Can you recommend any resources or documentation that provide in-depth explanations and solutions for this issue?&lt;br&gt;
I've searched online but found limited information on this topic. Any detailed explanations or pointers to comprehensive resources would be greatly appreciated.&lt;/p&gt;

&lt;p&gt;You Can see my db structure below: &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5afw4s9qmn7qkg2384al.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5afw4s9qmn7qkg2384al.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thank you!&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>dotnet</category>
      <category>dotnetcore</category>
      <category>aspdotnet</category>
    </item>
  </channel>
</rss>
