Exception when using Firebase streaming

Yusuf-3141 45 Reputation points
2024-10-18T05:54:17.3033333+00:00

Hi,
When I try to read data from Firebase using FirebaseDatabase.net Library I receive Newtonsoft.Json.JsonReaderException exeption

this code works


Imports Firebase.Database
Imports Firebase.Database.Query
Public Class Form1
    Private Async Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim client As New FirebaseClient("https://abcd.asia-southeast1.firebasedatabase.app/")
        Dim gesture = Await client _
            .Child("gestures") _
            .Child("last_gesture") _
            .OnceSingleAsync(Of String)()
        If gesture IsNot Nothing Then
            Label1.Text = gesture
        Else
            Label1.Text = "..."
        End If
        Console.WriteLine(gesture)
    End Sub
End Class


but this code does not work when using streaming

Imports Firebase.Database
Imports Firebase.Database.Query
Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim client As New FirebaseClient("https://abcd.asia-southeast1.firebasedatabase.app/")
        client.Child("gestures").Child("last_gesture").AsObservable(Of String)() _
        .Subscribe(Sub(f)
                       Console.WriteLine(f.Object)
                       If f.Object IsNot Nothing Then
                           Label1.Invoke(Sub() Label1.Text = f.Object)
                       End If
                   End Sub)
    End Sub
End Class


How can I solve this issue
Thank you in advance

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,896 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,729 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Love Text Hubs 0 Reputation points
    2024-10-18T08:41:19.9533333+00:00

    Encountering a JsonReaderException while using Firebase streaming in VB.NET can be frustrating. This error typically occurs due to improper JSON formatting or unexpected data types in your stream. To resolve this issue, ensure your JSON data adheres to the correct structure expected by Firebase. Additionally, check for null values or mismatched data types that might trigger the exception. Implementing robust error handling can also help you identify and troubleshoot issues quickly. By understanding the common causes of JsonReaderException, you can enhance your Firebase integration in VB.NET and ensure smoother data streaming experiences. Love Text Hubs

    0 comments No comments

  2. Yusuf-3141 45 Reputation points
    2024-10-20T23:35:24.6+00:00

    I think the issue not in firebase itself because i can read / write to it without problem the issue only hapen when try receive data using streaming i have reach this advanced stage of project and here is the project on Github
    https://github.com/devenv2/WinFormsApp1/tree/master

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.