In debug mode: Socket read timed out?

116 views
Skip to first unread message

john....@gmail.com

unread,
Mar 19, 2012, 9:42:45 AM3/19/12
to wr...@googlegroups.com
I've just implemented wro4j on my project, but have run into a problem when in development mode -- when wro4j is updating the model and cache every x seconds (I set my update to every 10 seconds).  Intermittently, as I develop and refresh my page, wro4j throws an "invalid resource" exception that is masking the real exception:  Socket Read Timed Out.  When this happens, url rewrites in css files fail, causing 404's all over the place.  Javascript handling is more tolerant, but does cause occasional socket timed out exceptions also.  Running in prod mode doesn't cause these issues.

What would be causing read timeouts locally in dev mode?

thanks,

John

Alex Objelean

unread,
Mar 19, 2012, 10:13:47 AM3/19/12
to wr...@googlegroups.com
The readTimeout error may be caused by a UrlUriLocator which is responsible for retrieving the stream for an external resource. The timeout value has by default value 2000 (2 seconds) and it is configurable (add connectionTimeout property to wro.properties).

Could you post the entire stacktrace, to be sure that this is the problem?

Thanks,
Alex
Message has been deleted
Message has been deleted

John Gordon

unread,
Mar 21, 2012, 9:17:17 AM3/21/12
to wr...@googlegroups.com
Alex,

I've been attempting to post a response to your request, but the post keeps disappearing.  Is the reply being inadvertently moderated?  Is there a preferable way to report details on this issue?

John

Alex Objelean

unread,
Mar 21, 2012, 9:20:19 AM3/21/12
to wr...@googlegroups.com
I've noticed that google groups is not very friendly from time to time. I would prefer the problem to be posted on mailing list, but if you have a problem, you can create an issue on google code or github and we can continue to discuss it there. 

Cheers,
Alex

--
You received this message because you are subscribed to the Google Groups "wro4j" group.
To view this discussion on the web visit https://groups.google.com/d/msg/wro4j/-/s2gYzlDjvZcJ.

To post to this group, send email to wr...@googlegroups.com.
To unsubscribe from this group, send email to wro4j+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/wro4j?hl=en.

John Gordon

unread,
Mar 21, 2012, 11:06:30 AM3/21/12
to wr...@googlegroups.com
I'm posting a screenshot of my IDE, perhaps google's choking on that.  The image shows the point where the exception is thrown and the stacktrace, plus the contents of the exception itself.  in this case, it may be worth a thousand words.  You can view it here:  http://gordonjl.com/files/wro4j_timeout.png

Thanks, again!

John
Alex

To unsubscribe from this group, send email to wro4j+unsubscribe@googlegroups.com.

Alex Objelean

unread,
Mar 21, 2012, 12:14:29 PM3/21/12
to wr...@googlegroups.com
It is quite strange that you get SocketTimeoutException while fetching servlet context resource. 
Could you step into uriLocatorFactory.locate() method? I'm curious where exactly the problem occurs.

If you want a quick fix, just increase the connectionTimeout configuration property to something like 5 (seconds).

Cheers,
Alex

To view this discussion on the web visit https://groups.google.com/d/msg/wro4j/-/QK5otuK4QZQJ.

To post to this group, send email to wr...@googlegroups.com.
To unsubscribe from this group, send email to wro4j+un...@googlegroups.com.

John Gordon

unread,
Mar 21, 2012, 1:54:05 PM3/21/12
to wr...@googlegroups.com
I've tried setting the connectionTimeout in wro.properties, but the value isn't actually being used within the code, oddly enough.

I'm using v1.4.4 of the library.

Here's a snippet from the WroConfiguration class that reads properties and sets them, notice connectionTimeout isn't being set:

public WroConfiguration create() {
    final WroConfiguration config = new WroConfiguration();
    if (properties != null) {
      config.setDebug(valueAsBoolean(properties.get(ConfigConstants.debug.name()), true));
      config.setGzipEnabled(valueAsBoolean(properties.get(ConfigConstants.gzipResources.name()), true));
      config.setJmxEnabled(valueAsBoolean(properties.get(ConfigConstants.jmxEnabled.name()), true));
      config.setCacheUpdatePeriod(valueAsLong(properties.get(ConfigConstants.cacheUpdatePeriod.name()), 0));
      config.setModelUpdatePeriod(valueAsLong(properties.get(ConfigConstants.modelUpdatePeriod.name()), 0));
      config.setDisableCache(valueAsBoolean(properties.get(ConfigConstants.disableCache.name()), false));
      config.setIgnoreMissingResources(valueAsBoolean(properties.get(ConfigConstants.ignoreMissingResources.name()), true));
      config.setEncoding(valueAsString(properties.get(ConfigConstants.encoding.name())));
      config.setWroManagerClassName(valueAsString(properties.get(ConfigConstants.managerFactoryClassName.name())));
      config.setMbeanName(valueAsString(properties.get(ConfigConstants.mbeanName.name())));
      config.setHeader(valueAsString(properties.get(ConfigConstants.header.name())));
      config.setCacheGzippedContent(valueAsBoolean(properties.get(ConfigConstants.cacheGzippedContent.name()), false));
      config.setParallelPreprocessing(valueAsBoolean(properties.get(ConfigConstants.parallelPreprocessing.name()), false));
    }
    LOG.debug("WroConfiguration created: {}", config);
    return config;
  }

I've done a search on the codebase to see if there's anywhere that calls WroConfiguration.setConnectionTimeout() -- the method is actually in WroConfiguration -- but it doesn't seem to be called.

Another item:  the connectionTimeout default setting is "2" -- the comments on the field say this is in 2 seconds, not milliseconds, as mentioned above.  This may explain why I would get timeout errors.  The code calling WroConfiguration.getConnectionTimeout() in DispatcherStreamLocater is treating this value as a millisecond:

     // setting these timeouts ensures the client does not deadlock indefinitely
        // when the server has problems.
        //TimeUnit.MILLISECONDS.con
        final int timeout = (int) TimeUnit.MILLISECONDS.convert(Context.get().getConfig().getConnectionTimeout(),
          TimeUnit.SECONDS);

What do you think?


John

John Gordon

unread,
Mar 21, 2012, 1:57:05 PM3/21/12
to wr...@googlegroups.com
Whoops.  I spoke too soon.  It _does_ look like the the 2 is being treated as seconds.  I misread the code.

John

Alex Objelean

unread,
Mar 21, 2012, 1:57:56 PM3/21/12
to wr...@googlegroups.com
That's a nice catch :)...
Probably forgot to set this value. Anyway, the 1.4.5 (next release) uses milliseconds instead of seconds confiuration. I will fix this problem also. 

Thanks for noticing.
Alex

To view this discussion on the web visit https://groups.google.com/d/msg/wro4j/-/kWkQ1AZ_1JQJ.

To post to this group, send email to wr...@googlegroups.com.
To unsubscribe from this group, send email to wro4j+un...@googlegroups.com.

John Gordon

unread,
Mar 21, 2012, 2:06:31 PM3/21/12
to wr...@googlegroups.com
Thanks, Alex.

I'll see about getting a stack trace to you re the original issue I had.  I wonder if it's a latency issue causing the read timeout, but 2 seconds for a local call seems very long.

John

Alex Objelean

unread,
Mar 21, 2012, 2:11:20 PM3/21/12
to wr...@googlegroups.com
I also think that there is something wrong with this latency. Don't want to make any assumption until I see a more detailed stacktrace.

Alex

To view this discussion on the web visit https://groups.google.com/d/msg/wro4j/-/nsOrRtb6FG0J.

To post to this group, send email to wr...@googlegroups.com.
To unsubscribe from this group, send email to wro4j+un...@googlegroups.com.

John Gordon

unread,
Mar 21, 2012, 3:52:55 PM3/21/12
to wr...@googlegroups.com
I'm still having issues identifying the exact location of the exception because the stack trace is empty and the PreProcessor is the only location where the exception is caught.  That said, I turned on debug level in log4j and i'm seeing the last debug statement is "Computed timeout milliseconds: 2000" logged within DispatcherStreamLocator -- then the call to UrlConnection.getInputStream() is made within DispatcherStreamLocator.  The UrlConnection.getInputStream() call will throw a SocketTimedOutException; I think this is where the exception is being thrown.

I think that's all I can do for now.  Good Luck!

John

Alex Objelean

unread,
Mar 21, 2012, 4:53:12 PM3/21/12
to wr...@googlegroups.com
I'm trying to reproduce the problem locally with no luck. 
I'm setting cacheUpdatePeriod to 10 seconds and trying to access a servlet context relative resource. Everything works as expected. 
Can you provide some more details? 
What OS do you use? What servlet container? Could it be something related to your dev environment? 

Thanks,
Alex


To view this discussion on the web visit https://groups.google.com/d/msg/wro4j/-/E5fiC190MzIJ.

To post to this group, send email to wr...@googlegroups.com.
To unsubscribe from this group, send email to wro4j+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages