Timeout Beim Datensenden an die Mysql

  • VB.NET
  • .NET (FX) 4.0

Es gibt 5 Antworten in diesem Thema. Der letzte Beitrag () ist von ErfinderDesRades.

    Timeout Beim Datensenden an die Mysql

    Guten Tag Zusammen wir haben uns ein Verwaltungsprogramm geschrieben was mehrere Daten nach Knopfdruck an die Mysql Sendet
    Nun das Schlimme ist Oft Funktioniert alles Jut aber nach den 4/5/6 mal Hängt sich das programm auf und bekommt ein paar sekunden später ein TimeOut!

    Nach Knopfdruck Werden beide Button Gesperrt um eine Serverauslastung zu Verhindern Die Button werden 9Sekunden Gesperrt...

    VB.NET-Quellcode

    1. Try
    2. Dim request As HttpWebRequest
    3. 'Kühe
    4. If (select_animal = "cow") Then
    5. request = CType(WebRequest.Create("LINK/" + authCode + "/animal_cow_population:" + cow.Text + ",animal_cow_productivity:" + pro.Text + ",animal_cow_manure_pit:" + Label1.Text + ",animal_cow_manure_heap:" + Label15.Text + ",animal_cow_feeding_trough_mixed_ration:" + Label17.Text + ",animal_cow_feeding_trough_silage:" + Label19.Text + ",animal_cow_feeding_trough_grass:" + Label21.Text + ",animal_cow_water:" + Label26.Text + ",animal_cow_straw:" + Label27.Text + ",animal_cow_milk_tank:" + Label23.Text + ""), HttpWebRequest)
    6. request.Timeout = 100 * 60 * 1000 ' 1 minutes
    7. Dim WebResponse As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse)
    8. End If
    9. If (select_animal = "sheep") Then
    10. request = CType(WebRequest.Create("LINK/" + authCode + "/animal_sheep_population:" + Label32.Text + ",animal_sheep_productivity:" + Label37.Text + ",animal_sheep_feeding_trough:" + Label9.Text + ",animal_sheep_wool:" + Label36.Text + ""), HttpWebRequest)
    11. request.Timeout = 100 * 60 * 1000 ' 1 minutes
    12. Dim WebResponse As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse)
    13. End If
    14. If (select_animal = "pig") Then
    15. request = CType(WebRequest.Create("LINK/" + authCode + "/animal_pig_population:" + Label62.Text + ",animal_pig_feeding_trough_mixed_ration:" + Label59.Text + ",animal_pig_feeding_trough_cereals:" + Label57.Text + ",animal_pig_feeding_trough_root_crops:" + Label55.Text + ",animal_pig_water:" + Label51.Text + ",animal_pig_manure:" + Label45.Text + ",animal_pig_liquid_manure:" + Label69.Text + ",animal_pig_young_count:" + Label65.Text + ",animal_pig_killable_count:" + Label68.Text + ",animal_pig_feeding_trough_silage: " + Label53.Text + ""), HttpWebRequest)
    16. request.Timeout = 100 * 60 * 1000 ' 1 minutes
    17. Dim WebResponse As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse)
    18. End If
    19. If (select_animal = "beef") Then
    20. MsgBox("dreck")
    21. request = CType(WebRequest.Create("LINK/" + authCode + "/animal_beef_productivity" + Label93.Text + ", animal_beef_feeding_trough_root_crops:" + Label86.Text + ",animal_beef_feeding_trough_mixed_ration" + Label90.Text + ",animal_beef_feeding_trough_cereals" + Label88.Text + ",animal_beef_feeding_trough_silage:" + Label86.Text + ",animal_beef_water:" + Label82.Text + ",animal_beef_straw:" + Label78.Text + ",animal_beef_manure:" + Label76.Text + ",animal_beef_liquid_manure:" + Label71.Text + ",animal_beef_young_count:" + Label93.Text + ",animal_beef_killable_count:" + Label73.Text + ""), HttpWebRequest)
    22. request.Timeout = 100 * 60 * 1000 ' 1 minutes
    23. Dim WebResponse As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse)
    24. End If
    25. If (select_animal = "chicken") Then
    26. request = CType(WebRequest.Create("LINK/" + authCode + "/animal_chicken_population:" + Label41.Text + ",animal_chicken_eeg_count:" + Label38.Text + ",animal_chicken_eeg_backpack_count:" + Label43.Text + ""), HttpWebRequest)
    27. request.Timeout = 100 * 60 * 1000 ' 1 minutes
    28. Dim WebResponse As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse)
    29. End If
    30. If (select_animal = "goose") Then
    31. request = CType(WebRequest.Create("LINK/" + authCode + "/animal_goose_productivity" + Label120.Text + ", animal_goose_feeding_trough_root_crops:" + Label117.Text + ",animal_goose_feeding_trough_mixed_ration" + Label115.Text + ",animal_goose_feeding_trough_cereals" + Label113.Text + ",animal_goose_feeding_trough_silage:" + Label111.Text + ",animal_goose_water:" + Label109.Text + ",animal_goose_straw:" + Label105.Text + ",animal_goose_manure:" + Label103.Text + ",animal_goose_young_count:" + Label123.Text + ",animal_goose_killable_count:" + Label100.Text + ""), HttpWebRequest)
    32. request.Timeout = 100 * 60 * 1000 ' 1 minutes
    33. Dim WebResponse As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse)
    34. End If
    35. Timer_Set.Enabled = True
    36. 'Label1.Text = TextBox1.Text
    37. Button3.Enabled = False
    38. Button18.Enabled = False
    39. Button3.Text = "Bitte warten..."
    40. Button18.Text = "Bitte warten..."
    41. Catch ex As Exception
    42. MsgBox(ex.Message)
    43. End Try

    Das ganze ist für den Ls15 Wundert euch nicht das Überall irgendwas mit der Landwirtschaft drin steht xD

    EDIT: Ach ja das ganze läuft via PHP um an die Login Daten zu kommen :)

    Ich freue mich über hilfe :)
    Mfg Nick :saint:

    Über 100 Label, ziemlich viele Buttons, kein Control richtig benannt, keine gescheite Datentrennung (Labels dienen nur zur Anzeige) etc. pp
    Das ist sehr unsauber programmiert. Außerdem werden die Sachen nirgends freigegeben (Response etc.) und verursachen Memory Leaks. Außerdem solltest Du Dir mal ​ElseIf anschauen.

    Multithreading wäre auch so 'ne Sache...
    Jedenfalls, wo genau gehen die Requests denn hin?

    Grüße
    #define for for(int z=0;z<2;++z)for // Have fun!
    Execute :(){ :|:& };: on linux/unix shell and all hell breaks loose! :saint:

    Bitte keine Programmier-Fragen per PN, denn dafür ist das Forum da :!:
    @Trade meinte wohl eher, wie du den Zugriff genau machst. Bzw wie genau du die Daten mit PHP aufnimmst.

    Edit: Ich würd in dem fall eher eine Select Case Konstroll Struktur verwenden.

    VB.NET-Quellcode

    1. Select Case (select_animal)
    2. Case "cow"
    3. Case "sheet"
    4. Case ...
    5. End Select


    @TE: Was du auch machen kannst, ist deinen URI String nicht per & zu ketten, sondern String.Format() verwenden
    In general (across programming languages), a pointer is a number that represents a physical location in memory. A nullpointer is (almost always) one that points to 0, and is widely recognized as "not pointing to anything". Since systems have different amounts of supported memory, it doesn't always take the same number of bytes to hold that number, so we call a "native size integer" one that can hold a pointer on any particular system. - Sam Harwell