Toon posts:

[ASP] ConnectionTimeout werkt niet?

Pagina: 1
Acties:

Verwijderd

Topicstarter
Ik heb een heel simpel stukje code:

ASP.NET Visual Basic:
1
2
3
4
5
6
7
dim conn
set conn = Server.CreateObject("ADODB.Connection")
conn.connectiontimeout = 3
conn.connectionstring = "Driver={SQL Server};Server=10.0.0.10;UID=user;PWD=pass"
conn.open
conn.close
set conn = nothing


Aangezien er op 10.0.0.10 geen SQL Server staat te draaien, behoort "conn.open" na 3 seconden (ConnectionTimeout) ermee te kappen.
Dat gebeurt echter niet. Het scriptje blijft zolang doorlopen, totdat er een ScriptTimeout optreedt.

Hoe zorg ik ervoor dat dit scriptje doet wat ik wil? (=na 3 seconden stoppen op instructie conn.open)

  • P_de_B
  • Registratie: Juli 2003
  • Niet online
Ik denk dat de oude ODBC driver die je gebruikt dit niet ondersteunt. Probeer de volgende connectiestring eens:

code:
1
Provider=sqloledb;Data Source=[server];Initial Catalog=[database];User Id=[user];Password=[pass];"

[ Voor 3% gewijzigd door P_de_B op 23-11-2005 14:18 ]

Oops! Google Chrome could not find www.rijks%20museum.nl


Verwijderd

Topicstarter
Nu heb ik dit:

ASP.NET Visual Basic:
1
2
3
4
5
6
7
dim conn
set conn = Server.CreateObject("ADODB.Connection")
conn.connectiontimeout = 3
conn.connectionstring = "Provider=sqloledb;Data Source=10.0.0.10;User Id=user;Password=airplane"
conn.open
conn.close
set conn = nothing


Maar nog steeds hetzelfde probleem... (ScriptTimeout)
(Ik zit trouwens op Windows XP, dus die bijgeleverde MDAC versie zou dit ook aan moeten kunnen...)

[ Voor 17% gewijzigd door Verwijderd op 23-11-2005 14:23 ]


  • joopst
  • Registratie: Maart 2005
  • Laatst online: 01-10-2024
volgens mijn msdn betekent die propertie iets anders dan wat jij hoopt.
Gets the time to wait while trying to establish a connection before terminating the attempt and generating an error.

  • Aram
  • Registratie: Februari 2004
  • Laatst online: 14-08-2025
Je hebt hier te maken met een andere timeout probleem. Op 10.0.0.10 draait niet alleen geen SQL Server, maar deze machine bestaat waarschijnlijk helemaal niet of is niet bereikbaar.

Neem voor de gein eens een machine die wel draait maar waar geen sql server op staat (te draaien). Dan zul je zien dat de ConnectionTimeout redelijk accuraat werkt.

  • P_de_B
  • Registratie: Juli 2003
  • Niet online
joopst schreef op woensdag 23 november 2005 @ 14:29:
volgens mijn msdn betekent die propertie iets anders dan wat jij hoopt.


[...]
Dat is toch wat hij hoopt?
If the time from the ConnectionTimeout property setting elapses prior to the opening of the connection, an error occurs and ADO cancels the attempt. If you set the property to zero, ADO will wait indefinitely until the connection is opened. Make sure the provider to which you are writing code supports the ConnectionTimeout functionality.

The ConnectionTimeout property is read/write when the connection is closed and read-only when it is open.

Oops! Google Chrome could not find www.rijks%20museum.nl


Verwijderd

Topicstarter
ADO 2.8 API Reference

ConnectionTimeout Property
Indicates how long to wait while establishing a connection before terminating the attempt and generating an error.

Settings and Return Values
Sets or returns a Long value that indicates, in seconds, how long to wait for the connection to open. Default is 15.

Remarks
Use the ConnectionTimeout property on a Connection object if delays from network traffic or heavy server use make it necessary to abandon a connection attempt. If the time from the ConnectionTimeout property setting elapses prior to the opening of the connection, an error occurs and ADO cancels the attempt. If you set the property to zero, ADO will wait indefinitely until the connection is opened. Make sure the provider to which you are writing code supports the ConnectionTimeout functionality.

The ConnectionTimeout property is read/write when the connection is closed and read-only when it is open.
Het probleem is dat ik met een redelijk aantal verschillende dynamische connecties werk (naar verschillende databases/servers), en dat er iemand zo stom kan zijn geweest om een fout IP adres op te geven.
Dit dat geval wil ik een nette melding terug geven, ipv een crash op een ScriptTimeout.

  • joopst
  • Registratie: Maart 2005
  • Laatst online: 01-10-2024
P_de_B schreef op woensdag 23 november 2005 @ 14:32:
[...]


Dat is toch wat hij hoopt?

[...]
8)7 what was i thinkin'

Verwijderd

Topicstarter
Zal ik dan maar een mailtje sturen naar support@microsoft.com? :P

Wanneer de computer in kwestie wél bestaat, dan werkt 'ie correct. Maar het lijkt me logischer dat, ongeacht welke situatie, 't script na x seconden een fout genereert (die je kan afvangen).

  • Aram
  • Registratie: Februari 2004
  • Laatst online: 14-08-2025
Als je de betreffende functionaliteit echt nodig hebt: kijk eens rond voor een makkelijk componentje waarmee je een GetHostByAddress() achtig aanroep kan doen om te kijken of de host in de lucht / bereikbaar is en pas daarna je connectie initialiseren.
Pagina: 1