atd-server-next icon indicating copy to clipboard operation
atd-server-next copied to clipboard

No response from server

Open pidugusundeep opened this issue 5 years ago • 7 comments

I tried running the script(https://github.com/Automattic/atd-server-next/blob/master/run.sh) and it always gives me an empty response. The sample request with the postman is attached below.

import http.client

conn = http.client.HTTPConnection("127.0.0.1:1049")

headers = {
    'key': "dashnine",
    'data': "iam wrting a wrong sentene",
    'cache-control': "no-cache",
    'postman-token': "8bd7b009-5488-c686-2dd9-444fd348d6ff"
    }

conn.request("POST", "/checkDocument", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))

Please let me know if I am missing something.

pidugusundeep avatar Feb 17 '20 08:02 pidugusundeep

Dear Sundeep

Please have a look at your models folder. You need some model binaries first to run the server. For this you can use the script https://github.com/Automattic/atd-server-next/blob/master/models/get_model_binaries.sh .

Best Regards Michael

On Mon, Feb 17, 2020 at 9:27 AM Sundeep [email protected] wrote:

I tried running the script( https://github.com/Automattic/atd-server-next/blob/master/run.sh) and it always gives me an empty response. The sample request with the postman is attached below.

import http.client

conn = http.client.HTTPConnection("127.0.0.1:1049")

headers = {

'key': "dashnine",

'data': "iam wrting a wrong sentene",

'cache-control': "no-cache",

'postman-token': "8bd7b009-5488-c686-2dd9-444fd348d6ff"

}

conn.request("POST", "/checkDocument", headers=headers)

res = conn.getresponse()

data = res.read()

print(data.decode("utf-8"))

Please let me know if I am missing something.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Automattic/atd-server-next/issues/1?email_source=notifications&email_token=ACQPES46UK6UC7IPNZJQVTTRDJC6FA5CNFSM4KWMZDDKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IN6QR3A, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACQPESYPXZNIFGWXWCRP6KLRDJC6FANCNFSM4KWMZDDA .

michaelharzheim avatar Feb 17 '20 13:02 michaelharzheim

Ran the script get_model_binaries.sh and it still shows me a blank result. <results></results>

pidugusundeep avatar Feb 20 '20 09:02 pidugusundeep

Dear Sundeep

Please add to your script

import urlib

and add the additional line

params = urllib.urlencode({'data': 'iam wrting a wrong sentene'})

then change the request to

conn.request("POST", "/checkDocument", body=params, headers=headers)


The headers is set to 0 when body is NULL for methods expecting a body like (PUT, POST, PATCH). The effect of the "None" - body is that the server gets an empty parms['data'] which causes an empty data tree, which you get also for correct sentences without any suggestions.

Best regards Michael

On Thu, Feb 20, 2020 at 10:12 AM Sundeep [email protected] wrote:

Ran the script get_model_binaries.sh and it still shows me a blank result.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Automattic/atd-server-next/issues/1?email_source=notifications&email_token=ACQPES5W3BSWBSNXPHYWBRLRDZCPFA5CNFSM4KWMZDDKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMMKH4I#issuecomment-588817393, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACQPES5XCIL7CY2KEVJ7LRDRDZCPFANCNFSM4KWMZDDA .

michaelharzheim avatar Feb 20 '20 15:02 michaelharzheim

Please replace

import urlib

by

import urllib

in my last contribution, an inconvenient typing error

Thanks, Michael

On Thu, Feb 20, 2020 at 10:12 AM Sundeep [email protected] wrote:

Ran the script get_model_binaries.sh and it still shows me a blank result.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Automattic/atd-server-next/issues/1?email_source=notifications&email_token=ACQPES5W3BSWBSNXPHYWBRLRDZCPFA5CNFSM4KWMZDDKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMMKH4I#issuecomment-588817393, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACQPES5XCIL7CY2KEVJ7LRDRDZCPFANCNFSM4KWMZDDA .

michaelharzheim avatar Feb 20 '20 15:02 michaelharzheim

I'm still using python 2.7.16 and have to use httplib instead of http.client

For http.client things are very similar

instead of

import urrlib params = urllib.urlencode({'data': 'iam wrting a wrong sentene'})

you can use

import urllib.parse params = urllib.parse.urlencode({'data': 'iam wrting a wrong sentene'})

Best regards Michael

On Thu, Feb 20, 2020 at 10:12 AM Sundeep [email protected] wrote:

Ran the script get_model_binaries.sh and it still shows me a blank result.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Automattic/atd-server-next/issues/1?email_source=notifications&email_token=ACQPES5W3BSWBSNXPHYWBRLRDZCPFA5CNFSM4KWMZDDKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMMKH4I#issuecomment-588817393, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACQPES5XCIL7CY2KEVJ7LRDRDZCPFANCNFSM4KWMZDDA .

michaelharzheim avatar Feb 20 '20 20:02 michaelharzheim

Thanks, this works.

import http.client
import urllib
conn = http.client.HTTPConnection("127.0.0.1:1049")

params = urllib.parse.urlencode({'data': 'iam wrting a wrong sentene'})
conn.request("POST", "/checkDocument", body=params)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))

Not sure if headers are mandatory??

pidugusundeep avatar Feb 21 '20 06:02 pidugusundeep

You are welcome !

From a general perspective the headers get more flexibility but I cannot see that we need it here

On Fri, Feb 21, 2020 at 7:26 AM Sundeep [email protected] wrote:

Thanks, this works.

import http.client import urllib conn = http.client.HTTPConnection("127.0.0.1:1049")

params = urllib.parse.urlencode({'data': 'iam wrting a wrong sentene'}) conn.request("POST", "/checkDocument", body=params)

res = conn.getresponse() data = res.read()

print(data.decode("utf-8"))

Not sure if headers are mandatory??

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Automattic/atd-server-next/issues/1?email_source=notifications&email_token=ACQPES4SWBM4XZRRP2POS5LRD5XZ3A5CNFSM4KWMZDDKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMRVFUQ#issuecomment-589517522, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACQPES2TNNZKVD3VCZHBPRDRD5XZ3ANCNFSM4KWMZDDA .

michaelharzheim avatar Feb 21 '20 17:02 michaelharzheim