简体   繁体   中英

Is there any timeout set in Django 1.4?

I have got an issue with Django 1.4 and with Soaplib 2.0.

When I send from my client a request with some large arguments, Django raised an exception and send an email of this type : " [Django] ERROR (EXTERNAL IP): Internal Server Error: /uri/to/soap/service "

Traceback (most recent call last):
File "/path/to/my/project/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 129, in get_response
raise ValueError("The view %s.%s didn't return an HttpResponse object." % (callback.__module__, view_name))

ValueError: The view myproject/library.soap.wsgi.view didn't return an HttpResponse object.

I use the normal @soap decorator available at http://soaplib.github.io/soaplib/2_0/pages/helloworld.html#declaring-a-soaplib-service on the server side.

So, it looks like this on the server configuration :

inside urls.py :

from myproject.server.webservice import WebService

application_view = Application([WebService], 'ws', name='ws').as_django_view()

urlpatterns = patterns(
     url(r'^soap/.*', csrf_exempt( application_view )),
)

inside myproject/server/webservice.py :

 from soaplib.core.service import DefinitionBase
 class WebService(DefinitionBase):
     '''
     The actual webservice class.
     This defines methods exposed to clients.
     '''
     def __init__(self, environ):
         '''
         This saves a reference to the request environment on the current instance
         '''
         self.environ = environ
         super(WebService, self).__init__(environ)

     @soap(Array(Array(String)), _returns=Integer)
     def my_method(self, params):
         return self.process(params)

     def process(self, params):
         #DO SOMETHING HERE

On the client side :

 #cfg is my configuration file
 #params is a dictionary 
 client = SoapClient(
                location = cfg.location,
                action = cfg.action, # SOAPAction
                namespace = cfg.namespace, #"http://example.com/sample.wsdl",
                soap_ns= cfg.soap_ns,
                trace = cfg.trace,
                ns = cfg.ns)
 response = client.my_method(params=params)

I have tried to send very large dictionary from my client and it does not work.

I suspect Django to set a timeout and to close my connection during the process. Is there anyway to increase the timeout or is the problem caused by something else ?

By the way, I use Django only. I did not configure any Apache or Nginx.

Your process(self, params) method does not do anything (in fact as it is currently it's not even valid python because a method needs to have a least one line of code after the signature). You should return some values there which can be used to create a valid soap response.

As a side note I'd recommend not using soaplib anymore. It goes supersided by rpclib which in turn is now called spyne. Also there are other soap server libraries available which focus more on the SOAP part (eg pysimplesoap, soapfish). I found that helpful because there tend to be less abstractions in between the SOAP xml and the actual implementation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM