Programmatically set WCF timeout in debug mode

I’m using WCF in communication between a server and client (both written in C#). In release-mode, the timouts should be set to ~20 seconds, but in debug mode I want to set them to a higher value so that I can debug/step in my code without the timeout occurring. I know that I can change … Read more

System.Net.Mail.SmtpException: Service not available, closing transmission channel. The server response was: 4.4.2

I get this error when I’m frequently sending some e-mail to a list of users. Say it sends 10 mails and 1 gives an error, then sends a couple more mails and gives the same error. The code looks like this: public static bool SendEmail(string toMail, string fromname, string from, string subject, string body, string … Read more

Timeout function using threading in python does not work

I have found a code creating a timeout function here, which does not seem to work. The complete test code is below: def timeout(func, args=(), kwargs={}, timeout_duration=1, default=None): import threading class InterruptableThread(threading.Thread): def __init__(self): threading.Thread.__init__(self) self.result = None def run(self): try: self.result = func(*args, **kwargs) except: self.result = default it = InterruptableThread() it.start() it.join(timeout_duration) if … Read more

Java HTTPUrlConnection timeout does not work

I’ve written a programm that opens a httpurlconnection to a website through random proxies. My httpurlconnection is called conn. Now I know, that some of those proxies might be too slow, so i’ve set the timeout of the connection to 40000 milliseconds with conn.setConnectTimeout(40000) and conn.setReadTimeout(40000). After doing so, i got this code: long diff … Read more

Setting client-side timeout per request with Alamofire [swift]?

I’m trying to set a client-side timeout per request for Alamofire for Swift. The lead architect told me to set this on NSURLRequest, but I’m completely confused on how to actually do that in practice. Can someone who has done this give an example? Thanks! Answer I think this code may works. var alamofireManager : … Read more

SSL Socket connect timeout

How can I configure connect timeout for SSL Sockets in Java? For plain sockets, I can simply create new socket instance without any target endpoint using new Socket(), and then call connect(SocketAddress endpoint, int timeout) method. With SSL sockets, I cannot create new SSLSocket() and SSLSocketFactory.getDefault().createSocket() method with no endpoint throws UnsupportedOperationException with Unconnected sockets … Read more

Spring websocket timeout settings

I’m using the Spring websocket support. My question is how to set the websocket connection timeout. Now the connection is closed automatically after several minutes. I want the connection never to be closed. Here is my websocket handler: public class MyHandler implements WebSocketHandler { private Logger logger = LoggerFactory.getLogger(this.getClass()); class MyTimerTask extends TimerTask { private … Read more

Cancel C# 4.5 TcpClient ReadAsync by timeout

What would the proper way to cancel TcpClient ReadAsync operation by timeout and catch this timeout event in .NET 4.5? TcpClient.ReadTimeout seems to be applied to the sync Read only. UPDATE: Tried tro apply the approach desribed here Cancelling an Asynchronous Operation var buffer = new byte[4096]; CancellationTokenSource cts = new CancellationTokenSource(5000); int amountRead = … Read more

mock a timeout url

I’m trying to mock a timeout from a webpage so that I can implement a “deal with timeout” feature. Basically what I need is a URL of something that does not reply within X seconds. Thanks in advance Here’s the code I have: var req = Components.classes[“;1”].createInstance(); req.overrideMimeType(‘text/plain; charset=utf-8’);“GET”, configurationURL, false); req.variable = specificConfigurationURLTerminator; … Read more