#30503: ConnectionResetError: [WinError 10054] An existing connection was 
forcibly
closed by the remote host
-----------------------------------------+--------------------------------
               Reporter:  msrajkumar95   |          Owner:  nobody
                   Type:  Bug            |         Status:  new
              Component:  HTTP handling  |        Version:  2.2
               Severity:  Normal         |       Keywords:  paytm payments
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  0
                  UI/UX:  0              |
-----------------------------------------+--------------------------------
 I am getting below issue while processing paytm payments and returning
 back to my Django application.
 Below is my code in views.py

 {{{
 from django.http import HttpResponse
 from django.shortcuts import render
 from django.views.decorators.csrf import csrf_exempt
 from django.contrib.auth.decorators import login_required
 from django.conf import settings
 from paytm import checksum
 from paytm.models import PaymentHistory

 @login_required
 def payment(request):
     CALLBACK_URL = settings.HOST_URL + settings.PAYTM_CALLBACK_URL
     order_id = checksum.__id_generator__()

     bill_amount = request.POST['amount']
     if bill_amount:
         data_dict = {
                     'MID':settings.PAYTM_MERCHANT_ID,
                     'ORDER_ID':order_id,
                     'TXN_AMOUNT': bill_amount,
                     'CUST_ID':request.user.email,
                     'INDUSTRY_TYPE_ID':settings.PAYTM_INDUSTRY_TYPE,
                     'WEBSITE': settings.PAYTM_WEBSITE,
                     'CHANNEL_ID':'WEB',
                     'CALLBACK_URL':CALLBACK_URL,
                 }
         param_dict = data_dict
         param_dict['CHECKSUMHASH'] = checksum.generate_checksum(data_dict,
 settings.PAYTM_MERCHANT_KEY)
         return
 render(request,"paytm/payment.html",{'paytmdict':param_dict})
     return HttpResponse("Bill Amount Could not find. ?bill_amount=10")

 @login_required
 @csrf_exempt
 def response(request):
     if request.method == 'GET':
         return render(request, 'paytm/home.html')
     elif request.method == "POST":
         data_dict = {}
         for key in request.POST:
             data_dict[key] = request.POST[key]
         verify = checksum.verify_checksum(data_dict,
 settings.PAYTM_MERCHANT_KEY, data_dict['CHECKSUMHASH'])
         if verify:
             for key in request.POST:
                 if key == "BANKTXNID" or key == "RESPCODE":
                     if request.POST[key]:
                         data_dict[key] = int(request.POST[key])
                     else:
                         data_dict[key] = 0
                 elif key == "TXNAMOUNT":
                     data_dict[key] = float(request.POST[key])
             PaymentHistory.objects.create(user=request.user, **data_dict)
             return
 render(request,"paytm/response.html",{"paytm":data_dict})
         else:
             return HttpResponse("checksum verify failed")
     return HttpResponse(status=200)
 }}}

 Code in urls.py

 {{{
 from django.urls import path
 from paytm import views

 urlpatterns = [
     path('', views.response, name='home'),
     path('payment/', views.payment, name='payment'),
     path('response/', views.response, name='response'),
 ]
 }}}

 Here's my trace back exception details.

 {{{
 [12/May/2019 08:38:35] "POST /paytm/payment/ HTTP/1.1" 200 4005
 ----------------------------------------
 Exception happened during processing of request from ('127.0.0.1', 54543)
 Traceback (most recent call last):
   File "C:\Python\Python37\lib\socketserver.py", line 647, in
 process_request_thread
     self.finish_request(request, client_address)
   File "C:\Python\Python37\lib\socketserver.py", line 357, in
 finish_request
     self.RequestHandlerClass(request, client_address, self)
   File "C:\Python\Python37\lib\socketserver.py", line 717, in __init__
     self.handle()
   File "C:\Python\Python37\lib\site-
 packages\django\core\servers\basehttp.py", line
 171, in handle
     self.handle_one_request()
   File "C:\Python\Python37\lib\site-
 packages\django\core\servers\basehttp.py", line
 179, in handle_one_request
     self.raw_requestline = self.rfile.readline(65537)
   File "C:\Python\Python37\lib\socket.py", line 589, in readinto
     return self._sock.recv_into(b)
 ConnectionResetError: [WinError 10054] An existing connection was forcibly
 closed by
 the remote host
 ----------------------------------------
 [12/May/2019 08:39:25] "POST /paytm/response/ HTTP/1.1" 200 3154
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30503>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/055.443a6da33c36d9b155cc26190254dabc%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to