Zim

Web server don't work under Windows 7

Bug #862986 reported by Eugene Mikhantiev
22
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Zim
Fix Released
Medium
Unassigned

Bug Description

When I start Web server by pressing ">" button in dialog, Zim create TCP socket and everything looks like web server work. But when I try to connect to the server with Firefox, connection failed. This is probably not related to Windows Firewall.

Zim 0.53

Revision history for this message
Eugene Mikhantiev (mehanik) wrote :
description: updated
Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote : Re: [Bug 862986] [NEW] Web server don't work under Windows 7

Could you check the log file for zim and see if there is any error message ?
If you run zim with "-D" the log file should also have the incoming
requests, so it shows if you reach the server at all.

Having the exact error message from firefox would also help.

Revision history for this message
Eugene Mikhantiev (mehanik) wrote :

Sorry, where can I find log file?

Firefox says that Connection timeout expired

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote : Re: [Bug 862986] Re: Web server don't work under Windows 7

On Thu, Oct 6, 2011 at 10:21 AM, Eugene Mikhantiev <email address hidden>wrote:

> Sorry, where can I find log file?
>

It will be in the temp folder, typically C:\TEMP or similar

Firefox says that Connection timeout expired
>
>
Sounds like you might not be be connected to the server (log file can tell
you for sure). Maybe double check firewall / security settings ?

-- Jaap

Revision history for this message
Eugene Mikhantiev (mehanik) wrote :

Thank you, I found log file.

Changed in zim:
status: New → Confirmed
importance: Undecided → Medium
Revision history for this message
Sebastian Audet (smaudet) wrote :

I may have a patch for this.

In general it seems the server is broken on Windows, lots of fun problems with sockets misbehaving. Stuff like node and apache all work flawlessly here (and python's SimpleHTTPServer), zim's server is just plain broken.

Right now I have it working, but (on chrome at least) I have to refresh multiple times due to a socket read timeout. Once I figure out how to fix the timeout I'll submit the patch.

Revision history for this message
Sebastian Audet (smaudet) wrote :

Please find attached my patch.

Please note that this is not a perfect solution, however it does fix the problem, namely the server crashing after accessing the index page.

A better solution would be to implement a proper webserver and run zim as an app instance.

Built for zim 0.59, tested from command line and gui.

Note: due to the unstable nature of the current server implementation, there may be an occasional failure to connect to the server. Refreshing seems to fix this issue.

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

Thanks for the patch! Will check if I can apply it before the upcoming
release.

Agreed that we should move the server to just use the python standard
module like
SimpleHTTPServer and remove this hack version. Only consideration is that
server should be able to run in same process as the gtk main loop, using a
thread should take care of this I guess.

Regards,

Jaap

On Wed, Apr 10, 2013 at 11:04 PM, Sebastian Audet <email address hidden>wrote:

> Please find attached my patch.
>
> Please note that this is not a perfect solution, however it does fix the
> problem, namely the server crashing after accessing the index page.
>
> A better solution would be to implement a proper webserver and run zim
> as an app instance.
>
> Built for zim 0.59, tested from command line and gui.
>
> Note: due to the unstable nature of the current server implementation,
> there may be an occasional failure to connect to the server. Refreshing
> seems to fix this issue.
>
> ** Attachment added: "Server Bug Fix."
>
> https://bugs.launchpad.net/zim/+bug/862986/+attachment/3638545/+files/server_fix.bzr
>
> --
> You received this bug notification because you are subscribed to Zim.
> https://bugs.launchpad.net/bugs/862986
>
> Title:
> Web server don't work under Windows 7
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/zim/+bug/862986/+subscriptions
>

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

On Thu, Apr 11, 2013 at 8:41 AM, Jaap Karssenberg <
<email address hidden>> wrote:

> Thanks for the patch! Will check if I can apply it before the upcoming
> release.
>
> Agreed that we should move the server to just use the python standard
> module like
> SimpleHTTPServer and remove this hack version. Only consideration is that
> server should be able to run in same process as the gtk main loop, using a
> thread should take care of this I guess.
>

.. I mean wsgiref.simple_server

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

This actually works :)

>>>
from wsgiref.simple_server import make_server

from zim.notebook import resolve_notebook
from zim.www import WWWInterface

notebook, path = resolve_notebook(sys.argv[1])
app = WWWInterface(notebook)

httpd = make_server('', 8000, app)
print "Serving HTTP on port 8000..."

# Respond to requests until process is killed
httpd.serve_forever()

# Alternative: serve one request, then exit
httpd.handle_request()
<<<

On Thu, Apr 11, 2013 at 8:43 AM, Jaap Karssenberg <
<email address hidden>> wrote:

> On Thu, Apr 11, 2013 at 8:41 AM, Jaap Karssenberg <
> <email address hidden>> wrote:
>
>> Thanks for the patch! Will check if I can apply it before the upcoming
>> release.
>>
>> Agreed that we should move the server to just use the python standard
>> module like
>> SimpleHTTPServer and remove this hack version. Only consideration is that
>> server should be able to run in same process as the gtk main loop, using a
>> thread should take care of this I guess.
>>
>
> .. I mean wsgiref.simple_server
>

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

I will commit a patch later this week to move the whole thing to
simple server and support windows.

Btw. if you want to run zim in cgi mode, see
wsgiref.handlers.CGIHandler - you can make a very simple cgi wrapper
around zim.www.WWWInterface.

On Thu, Apr 11, 2013 at 9:55 AM, Jaap Karssenberg
<email address hidden> wrote:
> This actually works :)
>
>>>>
> from wsgiref.simple_server import make_server
>
> from zim.notebook import resolve_notebook
> from zim.www import WWWInterface
>
> notebook, path = resolve_notebook(sys.argv[1])
> app = WWWInterface(notebook)
>
>
> httpd = make_server('', 8000, app)
> print "Serving HTTP on port 8000..."
>
> # Respond to requests until process is killed
> httpd.serve_forever()
>
> # Alternative: serve one request, then exit
> httpd.handle_request()
> <<<
>
>
>
> On Thu, Apr 11, 2013 at 8:43 AM, Jaap Karssenberg
> <email address hidden> wrote:
>>
>> On Thu, Apr 11, 2013 at 8:41 AM, Jaap Karssenberg
>> <email address hidden> wrote:
>>>
>>> Thanks for the patch! Will check if I can apply it before the upcoming
>>> release.
>>>
>>> Agreed that we should move the server to just use the python standard
>>> module like
>>> SimpleHTTPServer and remove this hack version. Only consideration is that
>>> server should be able to run in same process as the gtk main loop, using a
>>> thread should take care of this I guess.
>>
>>
>> .. I mean wsgiref.simple_server
>
>

Revision history for this message
Sebastian Audet (smaudet) wrote :

Sorry, didn't see the previous messages!

If it helps any I wouldn't mind writing up another patch. But if you've already written the code for the patch and just need to update, I'll just wait. :)

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

Committed in rev659, basically deleted the whole Server class and using wsgiref simple server instead.

Changed in zim:
status: Confirmed → Fix Committed
Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

Fix released in zim 0.60.

Changed in zim:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.