[web2py] Re: unexpected end of stream - py4web
Hi I have try to use burp proxy for know at what ip I generate the request: but using a proxy server on 127.0.0.1:8080 and redirect the traffic on the 192.168.x.x (my-ip):3111 Using google chrome, the result is correct and I see all my record in db. Using the application it gave me an error: Failed to connect to /127.0.0.1:8080 I re-wrote the code and I taken out the task. now the code is like this: @action("produzione", method="GET") @action("produzione///") @action("produzione/") def produzione(db, idmac, datafrom=None, datato=None): object_list = [] sIstancePrd = "mssql4://{}:{}@{}/{}".format("", "", "", db) dbPrd = DAL(sIstancePrd, folder=settings.DB_FOLDER, pool_size=settings. DB_POOL_SIZE, migrate_enabled=False) dbPrd.define_table( 'Produzione', Field('ID','id'), Field('DataLoggerID', type='integer'), Field('DataLoggerIDRiga', type='integer'), Field('Utente', type='integer'), Field('Commessa', type='string'), Field('Lotto', type='string'), Field('Fase', type='integer'), Field('Programma', type='string'), Field('OraInizio',type='datetime',default=lambda r:datetime.datetime .now()), Field('OraProgrammazione',type='datetime',default=lambda r:datetime. datetime.now()), Field('OraAttrezzaggio',type='datetime',default=lambda r:datetime. datetime.now()), Field('OraPrimoPezzo',type='datetime',default=lambda r:datetime. datetime.now()), Field('OraProduzione',type='datetime',default=lambda r:datetime. datetime.now()), Field('OraFine',type='datetime',default=lambda r:datetime.datetime. now()), Field('NPieghe', type='integer'), Field('Macchina', type='integer'), Field('PezziProdotti', type='integer')) try: if datafrom != None and datato != None: sSQL = "SELECT * FROM Produzione WHERE OraInizio>='{}' AND OraFine<='{}' AND Macchina={}".format(datafrom, datato, idmac) rows = dbPrd.executesql(sSQL) else: rows = dbPrd(dbPrd.Produzione.Macchina == idmac).select() for record in rows: d = collections.OrderedDict() d['ID'] = record.ID d['DataLoggerID'] = record.DataLoggerID d['DataLoggerIDRiga'] = record.DataLoggerIDRiga d['Utente'] = record.Utente if (record.Utente != None) else 0 d['Commessa'] = str(record.Commessa) d['Lotto'] = str(record.Lotto) d['Fase'] = record.Fase if (record.Fase != None) else 0 d['Programma'] = str(record.Programma) d['OraInizio'] = str(record.OraInizio) d['OraProgrammazione'] = str(record.OraProgrammazione) d['OraAttrezzaggio'] = str(record.OraAttrezzaggio) d['OraPrimoPezzo'] = str(record.OraPrimoPezzo) d['OraProduzione'] = str(record.OraProduzione) d['OraFine'] = str(record.OraFine) d['NPieghe'] = record.NPieghe if (record.NPieghe != None) else 0 d['Macchina'] = record.Macchina if (record.Macchina != None) else 0 d['PezziProdotti'] = record.PezziProdotti if (record. PezziProdotti != None) else 0 object_list.append(d) except Exception as inst: if settings.LOG_ENABLE: with open(settings.LOG_PATH, "a+") as f: f.write("Error Type: {}, Error: {}".format(type(inst), inst )) else: print ("Error Type: {}, Error: {}".format(type(inst), inst)) return json.dumps(object_list) but when I try to use getAsync() on the application it generate anyway the error: "Unexpected end of stream" Normaly in the application I generate an http request. someone know why or can help me for looking some forum or something else for resolve this issue. Thanks Edoardo Torrini Il giorno giovedì 27 febbraio 2020 02:38:06 UTC+1, Dave S ha scritto: > > > > On Tuesday, February 25, 2020 at 12:52:46 AM UTC-8, Edoardo Torrini wrote: >> >> Hi Dave, >> thanks for the reply, but I have notice that the code is wrong, I will >> explain. >> Since I need three function in task I used another one to collector and >> after I redirect by an if statement. >> > > Okay, the correction takes care of my surprise, and I re-read your other > thread with that in mind. > > I am not sure why you are using a task; but that's a side issue. > > Do I understand the results correctly? > > * you have two versions, one with task and a test version without a task > * both versions run ok with browser-initiated requests > * the task version does not run ok from the client > > Does the test version run ok from the client? > > does the GetAsync() call generate an HTTP(S) request? Have you looked at > the request details in either log files or with Christian's suggestion of > burp suite and compared that to the browser request? How long does it take > for the task to start and run?
[web2py] Re: unexpected end of stream - py4web
On Tuesday, February 25, 2020 at 12:52:46 AM UTC-8, Edoardo Torrini wrote: > > Hi Dave, > thanks for the reply, but I have notice that the code is wrong, I will > explain. > Since I need three function in task I used another one to collector and > after I redirect by an if statement. > Okay, the correction takes care of my surprise, and I re-read your other thread with that in mind. I am not sure why you are using a task; but that's a side issue. Do I understand the results correctly? * you have two versions, one with task and a test version without a task * both versions run ok with browser-initiated requests * the task version does not run ok from the client Does the test version run ok from the client? does the GetAsync() call generate an HTTP(S) request? Have you looked at the request details in either log files or with Christian's suggestion of burp suite and compared that to the browser request? How long does it take for the task to start and run? Sorry I'm not more help, I've been "watching" py4web but haven't actually used it, and the same for celery, so I've not dived into the request details or more of scheduling than the celery tutorial. Good luck! Dave /dps -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/48d8ffab-3b31-4729-98f0-6eb3c0a83965%40googlegroups.com.
[web2py] Re: unexpected end of stream - py4web
Hi Dave, thanks for the reply, but I have notice that the code is wrong, I will explain. Since I need three function in task I used another one to collector and after I redirect by an if statement. So I have the funtion: my_task(func, filtri, *argv) and the function produzione(dbnow, filtri, *argv). In the example I have synthesized the by putting only one function. The correct one that I have test a lot of time is: def produzione(dbnow, filtri, *argv): object_list = [] if filtri == 0: rows = dbnow(dbnow.Produzione.ID != None).select() else: data1 = fixDate(argv[Filter.DataIn.value]) data2 = fixDate(argv[Filter.DataFin.value]) rows = dbnow((dbnow.Produzione.OraInizio >= data1)&(dbnow.Produzione .OraInizio <= data2)&(dbnow.Produzione.Macchina == argv[Filter.IdMac.value ])).select() for record in rows: d = collections.OrderedDict() d['ID'] = record.ID d['DataLoggerID'] = record.DataLoggerID d['DataLoggerIDRiga'] = record.DataLoggerIDRiga d['Utente'] = record.Utente if (record.Utente != None) else 0 d['Commessa'] = str(record.Commessa) d['Lotto'] = str(record.Lotto) d['Fase'] = record.Fase if (record.Fase != None) else 0 d['Programma'] = str(record.Programma) d['OraInizio'] = str(record.OraInizio) d['OraProgrammazione'] = str(record.OraProgrammazione) d['OraAttrezzaggio'] = str(record.OraAttrezzaggio) d['OraPrimoPezzo'] = str(record.OraPrimoPezzo) d['OraProduzione'] = str(record.OraProduzione) d['OraFine'] = str(record.OraFine) d['NPieghe'] = record.NPieghe if (record.NPieghe != None) else 0 d['Macchina'] = record.Macchina if (record.Macchina != None) else 0 d['PezziProdotti'] = record.PezziProdotti if (record.PezziProdotti != None) else 0 object_list.append(d) return json.dumps(return object_list) Moreover if I run the request for a Browser and I can see the right result. I hope I was clear in the explanation Edoardo Torrini Il giorno martedì 25 febbraio 2020 07:36:15 UTC+1, Dave S ha scritto: > > > > On Sunday, February 23, 2020 at 11:26:50 PM UTC-8, Edoardo Torrini wrote: >> >> Hi, >> I will attach you some part of code: >> >> >> >> >> this is the task of my app: >> >> [image: task prd - py4web.png] >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> I am still surprised by that last line. >> > > Wouldn't the return exit produzione() while evaluating object_list and > before actually calling the json.dumps() ? > > /dps > > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/066365ac-d359-4224-9a40-7642eacfcabf%40googlegroups.com.
[web2py] Re: unexpected end of stream - py4web
On Sunday, February 23, 2020 at 11:26:50 PM UTC-8, Edoardo Torrini wrote: > > Hi, > I will attach you some part of code: > > > > > this is the task of my app: > > [image: task prd - py4web.png] > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > I am still surprised by that last line. > Wouldn't the return exit produzione() while evaluating object_list and before actually calling the json.dumps() ? /dps -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/dee3cad1-f72c-493f-a165-4b956cd82c84%40googlegroups.com.
[web2py] Re: unexpected end of stream - py4web
Hi, I will attach you some part of code: The client is written in c# and is implemented in Xamarin: [image: Exception - Xamarine.png] The server is written in python using the py4web framework, I have implemented the scheduling with celery/redis: This is the controller of my app: [image: Controller - py4web.png] this is the task of my app: [image: task prd - py4web.png] Thanks for your help. Edoardo Torrini Il giorno domenica 23 febbraio 2020 00:44:14 UTC+1, Massimo Di Pierro ha scritto: > > Can you show us some minimum code to rproduce? > > On Friday, 21 February 2020 20:38:08 UTC-8, Edoardo Torrini wrote: >> >> Hi >> >> I create a project client/server compose by an application mobile >> (client) and a webservice (py4web). >> the application create request to the webservice and the server reply. >> I add a request scheduling using the celery and redis. >> I follow pass for pass the guide on the official py4web site. >> >> the problem is that when I generete the get request from the app create >> an exception: "unexpected end of stream" >> Someone know how to fix this issue? >> >> Thanks >> Edoardo Torrini >> > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/6a55c277-f454-4cd5-b2ed-c11033fb9347%40googlegroups.com.
[web2py] Re: unexpected end of stream - py4web
Can you show us some minimum code to rproduce? On Friday, 21 February 2020 20:38:08 UTC-8, Edoardo Torrini wrote: > > Hi > > I create a project client/server compose by an application mobile (client) > and a webservice (py4web). > the application create request to the webservice and the server reply. > I add a request scheduling using the celery and redis. > I follow pass for pass the guide on the official py4web site. > > the problem is that when I generete the get request from the app create an > exception: "unexpected end of stream" > Someone know how to fix this issue? > > Thanks > Edoardo Torrini > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/1483d926-2e83-440b-ba2f-21aa2c5c6840%40googlegroups.com.