German TCP/IP Verbindung kann nicht aufgebaut werden

OliverA

Expert
Licensed User
Longtime User
Aber, wenn ich die HW vom Netz trenne, dann ist die Timeout Zeit wieder unter 1 sekunde
Funktioniert oder funktioniert es nicht? Was ist mit der Faszination mit dem Timeout?
 

Sinan Tuzcu

Well-Known Member
Licensed User
Longtime User
Funktioniert oder funktioniert es nicht? Was ist mit der Faszination mit dem Timeout?
Die Timeout Zeit wird nicht berücksichtigt.
Eingestellt 10sek. HW vom Fritzbox getrennt.
Und keine 1sek., bricht die Versuchsaufbau ab.
 

Sinan Tuzcu

Well-Known Member
Licensed User
Longtime User
Hätte gehofft, das Try Catch den Aufbau länger hält wie folgt, leider ohne Erfolg

B4X:
public Sub ConnectToServer
Try   
    If AStreams.IsInitialized Then AStreams.Close
    If Socket1.IsInitialized Then Socket1.Close
    
    Dim sock As Socket
    Socket1 = sock
    Socket1.Initialize("Socket1")
    
    Socket1.Connect(Variablen.IPaddress, Variablen.Port, 10000)
    
        Wait For Socket1_Connected (Successful As Boolean)
    
        
    If Successful Then
        'AStreams.Initialize(Socket1.InputStream,Socket1.OutputStream,"Astreams")
        
        Dim aStream As AsyncStreams
        AStreams = aStream
        AStreams.Initialize(Socket1.InputStream,Socket1.OutputStream,"Astreams")
        LOGIN_QUERY(CreateMap("FName":Variablen.Vorname,"LName":Variablen.Nachname,"email":Variablen.Email,"PassW":Variablen.PWlogin))
    End If

Catch
        Log(LastException.Message)
        MsgboxAsync(LastException.Message,"")
        If AStreams.IsInitialized Then AStreams.Close
        If Socket1.IsInitialized Then Socket1.Close
       
End Try
  
End Sub

In den Catch kommt es erst gar nicht rein.
 

OliverA

Expert
Licensed User
Longtime User
Die Timeout Zeit wird nicht berücksichtigt.
It is, you just don't know how network timeouts work. BTW, I'm done with German for now, since Standard American English is a tad simpler for me
Aber, wenn ich die HW vom Netz trenne
You are disconnecting your hardware and you expect what? For the system to wait 10 seconds before it times out? It could, but what you did not count on is your Fritz box. It probably notices that you disconnected the cable. Smart as it is, it knows what device(s) are/were available on that port. Now if something from the outside tries to connect to those boxes, the Fritz box just hangs up the connection. No 10 second timeout, since the Fritz box knows nothing about it. On your end, the dropped connection is seen and the connection stops. Period. There is no retrying at this point. You are really killing me. Every post you seem to change the goal post and/or don't really seem to explain very well what you want. You seem to refuse or you just don't plain know how to have logs appear in Release mode and even then you seem to refuse to use Debug mode, otherwise you should be seeing the underlying Java framework complaining. In this case, it probably would have told you that the connection was refused (or something like that) which would provide you with a hint that you are not dealing with a timeout situation. If you want an actual "retry" period of 10 seconds, where you just keep trying to connect, even though connections are refused, you'll have to code your own retry logic. The network layer is not going to do it for you.
 

Sinan Tuzcu

Well-Known Member
Licensed User
Longtime User
I do not think so. Because I also wrote a software in VB.net, and there is the 10 seconds considered.
This code works.
I have disconnect the Network cable, and it try 10 sec. and show me msgbox with Error after catch.

VB.net code
B4X:
Public serverStream As NetworkStream
Public clientSocket As New System.Net.Sockets.TcpClient()   

Public Sub CreateTCPConnection()
    Try
        clientSocket.Connect(System.Net.IPAddress.Parse(My.Settings.ServerIP), My.Settings.ServerPort)
        ConnectionStatusLbl.Text = "Connection: Connected"
        ConnectionStatusPB.Image = My.Resources.LED_Green
        clientSocket.SendTimeout = 10000 
     
    Catch ex As Exception
        ConnectionStatusLbl.Text = "Connection: Not Connected"
        clientSocket.Close()
        MsgBox(ex.ToString)
    End Try


End Sub
 

OliverA

Expert
Licensed User
Longtime User
clientSocket.SendTimeout = 10000
does not equal
Socket1.Connect(Variablen.IPaddress, Variablen.Port, 10000)
In the first case, Microsoft documents explicitly states
The SendTimeout property determines the amount of time that the Send method will block until it is able to return successfully
Whereas Android
The connection will then block until established or an error occurs.
Two different things. In Android's case, the connection is refused (and yes, I'm still guessing here since you're not logging anything) and since that is an error, Android errors out. In VB's case it looks like it is retrying for you. But that is VB's implementation of a socket feature, not a "standard" socket feature.

Update: Forgot to provide links:
Microsoft: https://docs.microsoft.com/en-us/do....7.2#System_Net_Sockets_TcpClient_SendTimeout
Android: https://developer.android.com/reference/java/net/Socket.html#connect(java.net.SocketAddress, int)
 

DonManfred

Expert
Licensed User
Longtime User
Try Catch den Aufbau länger hält wie folgt
Try Catch halt gar nix an.

Ich empfehle es mal KOMPLETT ohne Try Catch laufen zu lassen. Wenn ein Fehler auftritt dann crasht die app. In dem Fall check das Log (evtl. Unfiltered). Da MUSS eine Fehlermeldung stehen.
 

GMan

Well-Known Member
Licensed User
Longtime User
BERATUNGSRESISTENT ist ein Wort, das mir hier immer wieder einfällt :p
 

pucki

Active Member
Licensed User
Er macht das Try Catch nicht richtig. ;)

Try - Catch hat nur EINEN Job. Zu verhindern das die App / Programm crasht. Während der Entwicklung (ich mache es auch hinterher) lässt man sich die Fehlermeldung / Fehlercode anzeigen. Danach kann die App ordnungsgemäß aus den Speicher fliegen. ;) Wichtig ist für mich als Entwickler WARUM die App crasht.

Manchmal mache ich folgendes. Ich fange logische Fehler ab. Lese im Programm den Fehlercode aus, und übersetze ihn für den User.
z.b. :
If Fehlercode = 1234 then msgbox ("Fehler beim Aufbau der Verbindung","Problem", okonly) : fehlercode = 0
if not Fehlercode = 0 then msgbox ("Unbekannter Fehler Fehlercode "+Str(fehlercode)","Problem", okonly)

Wenn man das in der Reihenfolge macht, macht man es richtig. Und für mich als Entwickler hilft es weiter wenn ich den Fehlercode kenne.

Allerdings. !!! Mit irgendwelchen Sachen hat das alles NIX zu tun. Es ist ergo völlig egal ob man ein Try-Error macht oder nicht. Try-Error ist nur gut für den Kunden und mich als Entwickler um ein Programm besser zu machen.

Was die ganze Sache hier im Allgemeinen angeht, so kommt mir langsam der Verdacht, das man eine Software für etwas entwickeln will, wo der Hersteller zu geizig ist für Infos. Und man selbst auch Angst hat, eigene Infos weiter zu geben, in ein relativ öffentlichen Bereich. Kann ich verstehen, aber dann muss man halt mit den Folgen leben. ;)

Ich persönlich kenne mich. Ich brauch meine Software nicht zu dokumentieren. Das ist der beste Schutz. Bevor Leute bei mir durchsteigen haben die das Teil 100 x schneller selbst neu gemacht. ;);)

Was das helfen angeht. Ich helfe gerne wenn ich kann. Ich kenne nämlich das Problem wenn man da hängt und nicht weiter kommt. Das Problem bei mir ist allerdings. Ich weiß das es viele gibt die besser sind als ich. Nur habe ich eine Menge Probleme einen zu finden wenn ich ihn brauche ;)


Kleine Idee am Rande. Diskutiere bei VB mal mit deiner Firewall (und zwar mit hoffentlich BEIDEN). Einige Firewalls reagieren bei "nicht heilig gesprochenen" Programmen ziemlich zickig.

Gruß

Pucki
 
Last edited:

mw71

Active Member
Licensed User
Longtime User
wir nähern uns der 100er marke......

- ist es weiterhin so das es mit IP geht und mit Namen (xxx.fritznet.com oder so) nicht ?? -> DNS Problem??
(am Rande, ich mache es auch über no-ip.org, geht besser)
- kannst du das Log mitlesen? Ich mache das per USB Kabel und Debug Mode im Device

Wie schon mehrfach geschrieben, da MUSS nach deiner Beschreibung ein Fehler kommen.
Du solltest entweder den Fehler, oder besser das Log, Posten oder mal sagen wo man eine Kristallkugel her bekommt.
 

GMan

Well-Known Member
Licensed User
Longtime User
ich hätte dann gerne drei .Eine in blau, eine in rosa und eine "mit Farbe egal" aber dafür mit Hühnchengeschmack für meinen Hund.
Ich eine mit TCP/IP-Connector, da kann der FS dann direkt testen :D:D:D
 

MarkusR

Well-Known Member
Licensed User
Longtime User
Ich benutze bei sowas immer das Ausschlussverfahren ..
 

GMan

Well-Known Member
Licensed User
Longtime User
:D
 

Sinan Tuzcu

Well-Known Member
Licensed User
Longtime User
Hallo Zusammen,

eine Kristallkugel habe ich nicht aber ich kann euch etwas besseres anbieten
900.jpg
 
Top