SOLVED

Unable to access brain deployed in docker using python script

%3CLINGO-SUB%20id%3D%22lingo-sub-2114827%22%20slang%3D%22en-US%22%3EUnable%20to%20access%20brain%20deployed%20in%20docker%20using%20python%20script%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2114827%22%20slang%3D%22en-US%22%3E%3CP%3EI%20imported%20exported%20brain%20from%20azure%20as%20Docker%20image.%3C%2FP%3E%0A%3CP%3ERan%20the%20container.%3C%2FP%3E%0A%3CP%3EVerified%20the%20webservice%20in%20postman.%26nbsp%3B%20Obtained%20the%20response.%3C%2FP%3E%0A%3CP%3EURL%3A%20http%3A%2F%2Flocalhost%3A5000%2Fv1%2Fprediction%3CBR%20%2F%3EMethod%3A%20Get%2FPost%3CBR%20%2F%3ESample%20Request%20body%3A%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%22x_position%22%3A%200.31%2C%3CBR%20%2F%3E%22x_velocity%22%3A%200.07%2C%3CBR%20%2F%3E%22angle_position%22%3A%2011.3%2C%3CBR%20%2F%3E%22angle_velocity%22%3A%200.8%3CBR%20%2F%3E%7D%3C%2FP%3E%0A%3CP%3ESample%20Response%3A%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%22command%22%3A%201.0%3CBR%20%2F%3E%7D%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBut%20on%20calling%20the%20endpoint%20using%20python%20code%2C%20the%20program%20is%20stuck%20with%20no%20response.%20Code%20as%20follows%3A%3C%2FP%3E%0A%3CP%3E%26gt%3B%26gt%3B%26gt%3B%20import%20requests%3CBR%20%2F%3E%26gt%3B%26gt%3B%26gt%3B%20endpoint%20%3D%20%22http%3A%2F%2Flocalhost%3A5000%2Fv1%2Fprediction%22%3CBR%20%2F%3E%26gt%3B%26gt%3B%26gt%3B%20state%20%3D%20%7B%3CBR%20%2F%3E...%20%22x_position%22%3A%200.31%2C%3CBR%20%2F%3E...%20%22x_velocity%22%3A%200.07%2C%3CBR%20%2F%3E...%20%22angle_position%22%3A%2011.3%2C%3CBR%20%2F%3E...%20%22angle_velocity%22%3A%200.8%3CBR%20%2F%3E...%20%7D%3CBR%20%2F%3E%26gt%3B%26gt%3B%26gt%3B%20requests.get(endpoint%2C%20json%3Dstate)%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2119546%22%20slang%3D%22en-US%22%3ERe%3A%20Unable%20to%20access%20brain%20deployed%20in%20docker%20using%20python%20script%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2119546%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F821192%22%20target%3D%22_blank%22%3E%40Kinshuman%3C%2FA%3E%26nbsp%3BThanks%20for%20your%20suggestion.%26nbsp%3B%20I%20have%20tried%20waiting%20for%2010%20mins%2C%20but%20have%20waited%20for%205%20mins%20several%20times.%26nbsp%3B%20But%20by%20verifying%20other%20recommendations%2Fsuggestions%20in%20this%20thread%2C%20the%20root%20cause%20is%20postman%20trying%20to%20keep%20the%20connection%20alive%20after%20a%20request.%26nbsp%3B%20With%20that%20header%20disabled%2C%20it%20works%20parallelly%20in%20both%20python%20and%20postman.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2119535%22%20slang%3D%22en-US%22%3ERe%3A%20Unable%20to%20access%20brain%20deployed%20in%20docker%20using%20python%20script%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2119535%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F671917%22%20target%3D%22_blank%22%3E%40erictr%3C%2FA%3E%26nbsp%3BThat's%20great.%26nbsp%3B%20I%20verified%20myself%2C%20disabling%20that%20hidden%20header%20and%20running%20in%20postman.%26nbsp%3B%20Now%20python%20code%20is%20also%20able%20to%20access.%26nbsp%3B%20Thanks%20for%20figuring%20out%20the%20root%20cause.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2118650%22%20slang%3D%22en-US%22%3ERe%3A%20Unable%20to%20access%20brain%20deployed%20in%20docker%20using%20python%20script%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2118650%22%20slang%3D%22en-US%22%3EThe%20error%20messages%20returned%20are%20not%20trivial.%3CBR%20%2F%3EI'm%20a%20bit%20out%20of%20the%20loop%20however%20in%20the%20error%20message%20we%20are%20given%20some%20help%20with%20the%20following%3A%3CBR%20%2F%3EB4%20request%3CBR%20%2F%3ETraceback%20(most%20recent%20call%20last)%3A%3CBR%20%2F%3EFile%20%22C%3A%5CUsers%5Csubkris%5CMiniconda3%5Clib%5Csite-packages%5Curllib3%5Cconnectionpool.py%22%2C%20line%20426%2C%20in%20_make_request%3CBR%20%2F%3Esix.raise_from(e%2C%20None)%3CBR%20%2F%3EFile%20%22%3CSTRING%3E%22%2C%20line%203%2C%20in%20raise_from%3CBR%20%2F%3EFile%20%22C%3A%5CUsers%5Csubkris%5CMiniconda3%5Clib%5Csite-packages%5Curllib3%5Cconnectionpool.py%22%2C%20line%20421%2C%20in%20_make_request%3CBR%20%2F%3Ehttplib_response%20%3D%20conn.getresponse()%3CBR%20%2F%3EFile%20%22C%3A%5CUsers%5Csubkris%5CMiniconda3%5Clib%5Chttp%5Cclient.py%22%2C%20line%201332%2C%20in%20getresponse%3CBR%20%2F%3Eresponse.begin()%3CBR%20%2F%3EFile%20%22C%3A%5CUsers%5Csubkris%5CMiniconda3%5Clib%5Chttp%5Cclient.py%22%2C%20line%20303%2C%20in%20begin%3CBR%20%2F%3Eversion%2C%20status%2C%20reason%20%3D%20self._read_status()%3CBR%20%2F%3EFile%20%22C%3A%5CUsers%5Csubkris%5CMiniconda3%5Clib%5Chttp%5Cclient.py%22%2C%20line%20264%2C%20in%20_read_status%3CBR%20%2F%3Eline%20%3D%20str(self.fp.readline(_MAXLINE%20%2B%201)%2C%20%22iso-8859-1%22)%3CBR%20%2F%3E%3CBR%20%2F%3EA%26nbsp%3Bstring%26nbsp%3Brepresents%20alphanumeric%20data.%20This%20means%20that%20a%26nbsp%3Bstring%26nbsp%3Bcan%20contain%20many%20different%20characters%2C%20but%20they%20are%20all%20considered%20as%20if%20they%20were%20text%2C%20even%20if%20the%20characters%26nbsp%3Bare%20numbers.%3CBR%20%2F%3E%3CBR%20%2F%3ELet's%20continue...%3CBR%20%2F%3E%3CBR%20%2F%3EFile%20%22C%3A%5CUsers%5Csubkris%5CMiniconda3%5Clib%5Csocket.py%22%2C%20line%20669%2C%20in%20readinto%3CBR%20%2F%3Ereturn%20self._sock.recv_into(b)%3CBR%20%2F%3Esocket.timeout%3A%20timed%20out%3CBR%20%2F%3EDuring%20handling%20of%20the%20above%20exception%2C%20another%20exception%20occurred%3A%3CBR%20%2F%3ETraceback%20(most%20recent%20call%20last)%3A%3CBR%20%2F%3EFile%20%22C%3A%5CUsers%5Csubkris%5CMiniconda3%5Clib%5Csite-packages%5Crequests%5Cadapters.py%22%2C%20line%20439%2C%20in%20send%3CBR%20%2F%3Eresp%20%3D%20conn.urlopen(%3CBR%20%2F%3EFile%20%22C%3A%5CUsers%5Csubkris%5CMiniconda3%5Clib%5Csite-packages%5Curllib3%5Cconnectionpool.py%22%2C%20line%20726%2C%20in%20urlopen%3CBR%20%2F%3Eretries%20%3D%20retries.increment(%3CBR%20%2F%3EFile%20%22C%3A%5CUsers%5Csubkris%5CMiniconda3%5Clib%5Csite-packages%5Curllib3%5Cutil%5Cretry.py%22%2C%20line%20410%2C%20in%20increment%3CBR%20%2F%3Eraise%20six.reraise(type(error)%2C%20error%2C%20_stacktrace)%3CBR%20%2F%3E%3CBR%20%2F%3ESo%20then%20the%20error%20is%20of%20a%20data%20type.%3CBR%20%2F%3EIt's%20looking%20like%20the%20data%20being%20returned%20to%20instruct%20your%20program%20to%20increment%20trying%20the%20url%20is%20not%20returning%20the%20data%20in%20the%20expected%20type%2C%20it%20recieving%20a%20string%20and%20it%20wants%20an%20integer...%20and%20it%20is...%3CBR%20%2F%3E%3CBR%20%2F%3EIline%20%3D%20str(self.fp.readline(_MAXLINE%20%2B%201)%2C%20%22iso-8859-1%22)%3CBR%20%2F%3E%3CBR%20%2F%3ESo%20then%20its%20a%20data%20type%20that's%20of%20the%20incorrect%20form%20....%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FSTRING%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2118461%22%20slang%3D%22en-US%22%3ERe%3A%20Unable%20to%20access%20brain%20deployed%20in%20docker%20using%20python%20script%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2118461%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F955928%22%20target%3D%22_blank%22%3E%40smartsubbu%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20you%20do%20in%20postman%20first%2C%20wait%20for%2010%20minutes%20and%20try%20the%20curl%20does%20it%20repro%3F%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2118458%22%20slang%3D%22en-US%22%3ERe%3A%20Unable%20to%20access%20brain%20deployed%20in%20docker%20using%20python%20script%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2118458%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F955928%22%20target%3D%22_blank%22%3E%40smartsubbu%3C%2FA%3E%26nbsp%3BThat's%20good%20news!%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe've%20found%20that%20postman%20adds%20a%20%22keep-alive%22%20header%20by%20default%2C%20and%20that's%20what%20causes%20this%20behavior.%20IIRC%2C%20there's%20a%20setting%20in%20postman%20to%20not%20specify%20this%20header.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2118404%22%20slang%3D%22en-US%22%3ERe%3A%20Unable%20to%20access%20brain%20deployed%20in%20docker%20using%20python%20script%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2118404%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F772203%22%20target%3D%22_blank%22%3E%40chetand%3C%2FA%3E%26nbsp%3BI%20never%20thought%20of%20this.%26nbsp%3B%20As%20you%20mentioned%2C%20I%20restarted%20the%20container%20and%20ran%20both%20my%20python%20program%20and%20curl%20command%20in%20bash%20without%20verifying%20in%20Postman.%26nbsp%3B%20Both%20worked%20fine.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECurl%20output%3A%3C%2FP%3E%0A%3CP%3E%3CFONT%20color%3D%22%230000FF%22%3E%26gt%3B%20--header%20'Content-Type%3A%20application%2Fjson'%20%5C%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%230000FF%22%3E%26gt%3B%20--data-raw%20'%7B%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%230000FF%22%3E%26gt%3B%20%22x_position%22%3A%200.31%2C%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%230000FF%22%3E%26gt%3B%20%22x_velocity%22%3A%200.07%2C%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%230000FF%22%3E%26gt%3B%20%22angle_position%22%3A%207.3%2C%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%230000FF%22%3E%26gt%3B%20%22angle_velocity%22%3A%200.8%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%230000FF%22%3E%26gt%3B%20%7D'%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%230000FF%22%3E%7B%22command%22%3A1.0%7D%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20color%3D%22%23000000%22%3EAny%20idea%2C%20why%20running%20in%20postman%20would%20be%20creating%20an%20issue.%26nbsp%3B%20Is%20it%20blocking%20all%20other%20connections%3F%3C%2FFONT%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2118383%22%20slang%3D%22en-US%22%3ERe%3A%20Unable%20to%20access%20brain%20deployed%20in%20docker%20using%20python%20script%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2118383%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F671917%22%20target%3D%22_blank%22%3E%40erictr%3C%2FA%3E%26nbsp%3BI%20tried%20the%20first%20curl%20command.%26nbsp%3B%20After%20waiting%20around%2010mins%20gave%20up.%26nbsp%3B%20Its%20stuck%20with%20this%20message%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20color%3D%22%230000FF%22%3E*%20Trying%20127.0.0.1%3A5000...%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%230000FF%22%3E*%20TCP_NODELAY%20set%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%230000FF%22%3E*%20Connected%20to%20localhost%20(127.0.0.1)%20port%205000%20(%230)%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%230000FF%22%3E%26gt%3B%20GET%20%2Fv1%2Fstatus%20HTTP%2F1.1%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%230000FF%22%3E%26gt%3B%20Host%3A%20localhost%3A5000%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%230000FF%22%3E%26gt%3B%20User-Agent%3A%20curl%2F7.68.0%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%230000FF%22%3E%26gt%3B%20Accept%3A%20*%2F*%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%230000FF%22%3E%26gt%3B%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EEven%20tried%20the%20second%20command%20and%20waited%20for%205%20mins.%26nbsp%3B%20No%20response%20after%20this%20message%3C%2FP%3E%0A%3CP%3E%3CFONT%20color%3D%22%230000FF%22%3E*%20Trying%20127.0.0.1%3A5000...%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%230000FF%22%3E*%20TCP_NODELAY%20set%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%230000FF%22%3E*%20Connected%20to%20localhost%20(127.0.0.1)%20port%205000%20(%230)%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%230000FF%22%3E%26gt%3B%20POST%20%2Fv1%2Fprediction%20HTTP%2F1.1%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%230000FF%22%3E%26gt%3B%20Host%3A%20localhost%3A5000%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%230000FF%22%3E%26gt%3B%20User-Agent%3A%20curl%2F7.68.0%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%230000FF%22%3E%26gt%3B%20Accept%3A%20*%2F*%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%230000FF%22%3E%26gt%3B%20Content-Type%3A%20application%2Fjson%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%230000FF%22%3E%26gt%3B%20Content-Length%3A%2087%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%230000FF%22%3E%26gt%3B%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%230000FF%22%3E*%20upload%20completely%20sent%20off%3A%2087%20out%20of%2087%20bytes%3C%2FFONT%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2118374%22%20slang%3D%22en-US%22%3ERe%3A%20Unable%20to%20access%20brain%20deployed%20in%20docker%20using%20python%20script%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2118374%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F955928%22%20target%3D%22_blank%22%3E%40smartsubbu%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EDo%20you%20see%20this%20same%20freezing%20behavior%20with%20a%20local%20container%20only%20after%20trying%20to%20run%20it%20with%20postman%2C%20or%20regardless%20of%20whether%20you've%20run%20with%20postman%20or%20not%3F%26nbsp%3B%20A%20quick%20test%20would%20be%20to%20restart%20the%20export%20brain%20container%20then%20try%20to%20access%20it%20with%20either%20curl%20or%20your%20python%20script%20as%20it's%20first%20request.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2117022%22%20slang%3D%22en-US%22%3ERe%3A%20Unable%20to%20access%20brain%20deployed%20in%20docker%20using%20python%20script%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2117022%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F955928%22%20target%3D%22_blank%22%3E%40smartsubbu%3C%2FA%3E%26nbsp%3BHere's%20another%20suggestion%20from%20another%20engineer%20on%20our%20team.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETry%20running%3A%3C%2FP%3E%0A%3CP%3E%60%60%60%3C%2FP%3E%0A%3CDIV%3Ecurl%20-v%20http%3A%3A%2Flocalhost%3A5000%2Fv1%2Fstatus%3C%2FDIV%3E%0A%3CDIV%3E%60%60%60%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3EIf%20that%20works%2C%20try%3A%3C%2FDIV%3E%0A%3CDIV%3E%60%60%60%3CDIV%3Ecurl%20-v%20-H%20%22Content-Type%3A%20application%2Fjson%22%20-d%20'%7B%22x_position%22%3A%200.31%2C%20%22x_velocity%22%3A%200.07%2C%20%22angle_position%22%3A%2011.3%2C%20%22angle_velocity%22%3A%200.8%7D'%20%3CA%20tabindex%3D%22-1%22%20title%3D%22http%3A%2F%2Flocalhost%3A5000%2Fv1%2Fprediction%22%20href%3D%22http%3A%2F%2Flocalhost%3A5000%2Fv1%2Fprediction%22%20target%3D%22_blank%22%20rel%3D%22noreferrer%20noopener%20nofollow%22%3Ehttp%3A%2F%2Flocalhost%3A5000%2Fv1%2Fprediction%3C%2FA%3E%3C%2FDIV%3E%0A%3CDIV%3E%60%60%60%3C%2FDIV%3E%0A%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2115845%22%20slang%3D%22en-US%22%3ERe%3A%20Unable%20to%20access%20brain%20deployed%20in%20docker%20using%20python%20script%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2115845%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F671917%22%20target%3D%22_blank%22%3E%40erictr%3C%2FA%3E%26nbsp%3BThe%20same%20python%20code%20works%20if%20I%20deploy%20in%20cloud%20in%20a%20acr%20and%20use%20the%20azurewebsites.net%2Fv1%2Fprediction%20url.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CEM%3E%3CFONT%20color%3D%22%230000FF%22%3E%7B%22x_position%22%3A%200.31%2C%20%22x_velocity%22%3A%200.07%2C%20%22angle_position%22%3A%2011.3%2C%20%22angle_velocity%22%3A%200.8%7D%3C%2FFONT%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%3CFONT%20color%3D%22%230000FF%22%3EB4%20request%3C%2FFONT%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%3CFONT%20color%3D%22%230000FF%22%3E%7B%22command%22%3A1.0%7D%3C%2FFONT%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%3CFONT%20color%3D%22%230000FF%22%3EEnd%20of%20program%3C%2FFONT%3E%3C%2FEM%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2115761%22%20slang%3D%22en-US%22%3ERe%3A%20Unable%20to%20access%20brain%20deployed%20in%20docker%20using%20python%20script%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2115761%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F671917%22%20target%3D%22_blank%22%3E%40erictr%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20was%20making%20several%20changes%20and%20forgot%20to%20include%20header.%26nbsp%3B%20But%20adding%20the%20header%20made%20no%20difference.%26nbsp%3B%20I%20changed%20the%20code%20to%20try%20other%20options%20you%20suggested%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%0A%3CDIV%3E%3CEM%3Eimport%26nbsp%3Brequests%3C%2FEM%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CEM%3Eimport%26nbsp%3Bjson%3C%2FEM%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CEM%3E%23url%26nbsp%3B%3D%26nbsp%3B%22http%3A%2F%2Flocalhost%3A5000%2Fv1%2Fprediction%22%3C%2FEM%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CEM%3Eurl%26nbsp%3B%3D%26nbsp%3B%22http%3A%2F%2Flocalhost%3A5000%2Fv1%2Fdummy%22%3C%2FEM%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CEM%3Epayload%3D%7B%3C%2FEM%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CEM%3E%22x_position%22%3A%26nbsp%3B0.31%2C%3C%2FEM%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CEM%3E%22x_velocity%22%3A%26nbsp%3B0.07%2C%3C%2FEM%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CEM%3E%22angle_position%22%3A%26nbsp%3B11.3%2C%3C%2FEM%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CEM%3E%22angle_velocity%22%3A%26nbsp%3B0.8%3C%2FEM%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CEM%3E%7D%3C%2FEM%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CEM%3Ejson_payload%26nbsp%3B%3D%26nbsp%3Bjson.dumps(payload)%3C%2FEM%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CEM%3Eprint(json_payload)%3C%2FEM%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CEM%3Eheaders%26nbsp%3B%3D%26nbsp%3B%7B%3C%2FEM%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CEM%3E%26nbsp%3B%26nbsp%3B'Content-Type'%3A%26nbsp%3B'application%2Fjson'%3C%2FEM%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CEM%3E%7D%3C%2FEM%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CEM%3Eprint(%22B4%26nbsp%3Brequest%22)%3C%2FEM%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CEM%3Eresponse%26nbsp%3B%3D%26nbsp%3Brequests.post(url%2C%26nbsp%3Bdata%3Djson_payload%2C%26nbsp%3Bheaders%3Dheaders)%3C%2FEM%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CEM%3Eprint(response.text)%3C%2FEM%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CEM%3Eprint(%22End%26nbsp%3Bof%26nbsp%3Bprogram%22)%3C%2FEM%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3EStill%20stuck%20at%20the%20requests%20line%20whether%20correct%20url%20or%20dummy%20url%20is%20specified.%26nbsp%3B%20Looks%20like%20its%20not%20even%20hitting%20the%20endpoint%3Aport%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%3CFONT%20color%3D%22%230000FF%22%3E%7B%22x_position%22%3A%200.31%2C%20%22x_velocity%22%3A%200.07%2C%20%22angle_position%22%3A%2011.3%2C%20%22angle_velocity%22%3A%200.8%7D%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%230000FF%22%3EB4%20request%3C%2FFONT%3E%3C%2FDIV%3E%0A%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2115660%22%20slang%3D%22en-US%22%3ERe%3A%20Unable%20to%20access%20brain%20deployed%20in%20docker%20using%20python%20script%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2115660%22%20slang%3D%22en-US%22%3E%3CP%3EThere's%20clearly%20something%20different%20about%20postman%20and%20the%20Python%20%60requests%60%20library%20are%20formulating%20the%20HTTP%20query.%20We%20need%20to%20figure%20out%20what's%20going%20wrong%20with%20the%20latter.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECan%20you%20confirm%20that%20you%20added%20the%20headers%20to%20the%20request%3F%20In%20your%20sample%20below%2C%20you%20define%20%60headers%60%2C%20but%20you%20don't%20pass%20it%20in%20to%20post%20call.%20I%20don't%20think%20that%20should%20matter%20because%20the%20documentation%20for%20%60requests%60%20says%20that%20if%20you%20pass%20an%20argument%20to%20the%20%60json%60%20parameter%2C%20the%20%60Content-Type%60%20will%20be%20set%20to%20%60application%2Fjson%60%20automatically.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAnother%20thought%20is%20to%20include%20the%20header%20_and_%20manually%20encode%20the%20json%20payload%20to%20ensure%20that%20it's%20properly%20formed.%20That%20way%2C%20you%20can%20print%20it%20out%20and%20examine%20it%20before%20it's%20sent.%3C%2FP%3E%0A%3CP%3E%60%60%60python%3C%2FP%3E%0A%3CP%3Ejson_payload%20%3D%20json.dumps(payload)%3C%2FP%3E%0A%3CP%3Eprint(json_payload)%3C%2FP%3E%0A%3CP%3Eresponse%20%3D%20requests.post(url%2C%20data%3Djson_payload%2C%20headers%3Dheaders)%3C%2FP%3E%0A%3CP%3E%60%60%60%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAnother%20idea%20is%20to%20modify%20the%20URL%20to%20%22http%3A%2F%2Flocalhost%3A5000%2Fv1%2Fdummy%22%20to%20see%20if%20you%20receive%20an%20error%20or%20a%20hang.%20That%20will%20tell%20us%20whether%20you're%20reaching%20the%20HTTP%20server%20within%20the%20container.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B-Eric%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2115543%22%20slang%3D%22en-US%22%3ERe%3A%20Unable%20to%20access%20brain%20deployed%20in%20docker%20using%20python%20script%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2115543%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F671917%22%20target%3D%22_blank%22%3E%40erictr%3C%2FA%3E%26nbsp%3BThanks%20for%20your%20suggestions.%26nbsp%3B%20I%20have%20already%20tried%20both%20get%20and%20post%2C%20but%20tried%20again%20today.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%0A%3CP%3E1.%20Restarted%20the%20container.%3C%2FP%3E%0A%3CP%3E2.%20Verified%20again%20in%20postman%20with%20Post%20method%20-%20Pass%3C%2FP%3E%0A%3CP%3E3.%20Ran%20a%20python%20code%20with%20Post%20method%20and%20including%20a%20header%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%0A%3CDIV%3E%3CEM%3Eimport%26nbsp%3Brequests%3C%2FEM%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CEM%3Eurl%26nbsp%3B%3D%26nbsp%3B%22http%3A%2F%2Flocalhost%3A5000%2Fv1%2Fprediction%22%3C%2FEM%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CEM%3Epayload%3D%7B%3C%2FEM%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CEM%3E%22x_position%22%3A%26nbsp%3B0.31%2C%3C%2FEM%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CEM%3E%22x_velocity%22%3A%26nbsp%3B0.07%2C%3C%2FEM%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CEM%3E%22angle_position%22%3A%26nbsp%3B11.3%2C%3C%2FEM%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CEM%3E%22angle_velocity%22%3A%26nbsp%3B0.8%3C%2FEM%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CEM%3E%7D%3C%2FEM%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CEM%3Eheaders%26nbsp%3B%3D%26nbsp%3B%7B%3C%2FEM%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CEM%3E%26nbsp%3B%26nbsp%3B'Content-Type'%3A%26nbsp%3B'application%2Fjson'%3C%2FEM%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CEM%3E%7D%3C%2FEM%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CEM%3Eprint(%22B4%26nbsp%3Brequest%22)%3C%2FEM%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CEM%3Eresponse%26nbsp%3B%3D%26nbsp%3Brequests.post(url%2C%26nbsp%3Bjson%3Dpayload%2C%26nbsp%3Btimeout%3D5)%3C%2FEM%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CEM%3Eprint(response.text)%3C%2FEM%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CEM%3Eprint(%22End%26nbsp%3Bof%26nbsp%3Bprogram%22)%3C%2FEM%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3Ewith%20the%20timeout%20attribute%2C%20I%20get%20the%20following%20error%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%0A%3CP%3E%3CFONT%20color%3D%22%230000FF%22%3E%3CEM%3EB4%20request%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3ETraceback%20(most%20recent%20call%20last)%3A%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3EFile%20%22C%3A%5CUsers%5Csubkris%5CMiniconda3%5Clib%5Csite-packages%5Curllib3%5Cconnectionpool.py%22%2C%20line%20426%2C%20in%20_make_request%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3Esix.raise_from(e%2C%20None)%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3EFile%20%22%3CSTRING%3E%22%2C%20line%203%2C%20in%20raise_from%3C%2FSTRING%3E%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3EFile%20%22C%3A%5CUsers%5Csubkris%5CMiniconda3%5Clib%5Csite-packages%5Curllib3%5Cconnectionpool.py%22%2C%20line%20421%2C%20in%20_make_request%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3Ehttplib_response%20%3D%20conn.getresponse()%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3EFile%20%22C%3A%5CUsers%5Csubkris%5CMiniconda3%5Clib%5Chttp%5Cclient.py%22%2C%20line%201332%2C%20in%20getresponse%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3Eresponse.begin()%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3EFile%20%22C%3A%5CUsers%5Csubkris%5CMiniconda3%5Clib%5Chttp%5Cclient.py%22%2C%20line%20303%2C%20in%20begin%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3Eversion%2C%20status%2C%20reason%20%3D%20self._read_status()%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3EFile%20%22C%3A%5CUsers%5Csubkris%5CMiniconda3%5Clib%5Chttp%5Cclient.py%22%2C%20line%20264%2C%20in%20_read_status%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3Eline%20%3D%20str(self.fp.readline(_MAXLINE%20%2B%201)%2C%20%22iso-8859-1%22)%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3EFile%20%22C%3A%5CUsers%5Csubkris%5CMiniconda3%5Clib%5Csocket.py%22%2C%20line%20669%2C%20in%20readinto%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3Ereturn%20self._sock.recv_into(b)%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3Esocket.timeout%3A%20timed%20out%3C%2FEM%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3EDuring%20handling%20of%20the%20above%20exception%2C%20another%20exception%20occurred%3A%3C%2FEM%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3ETraceback%20(most%20recent%20call%20last)%3A%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3EFile%20%22C%3A%5CUsers%5Csubkris%5CMiniconda3%5Clib%5Csite-packages%5Crequests%5Cadapters.py%22%2C%20line%20439%2C%20in%20send%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3Eresp%20%3D%20conn.urlopen(%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3EFile%20%22C%3A%5CUsers%5Csubkris%5CMiniconda3%5Clib%5Csite-packages%5Curllib3%5Cconnectionpool.py%22%2C%20line%20726%2C%20in%20urlopen%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3Eretries%20%3D%20retries.increment(%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3EFile%20%22C%3A%5CUsers%5Csubkris%5CMiniconda3%5Clib%5Csite-packages%5Curllib3%5Cutil%5Cretry.py%22%2C%20line%20410%2C%20in%20increment%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3Eraise%20six.reraise(type(error)%2C%20error%2C%20_stacktrace)%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3EFile%20%22C%3A%5CUsers%5Csubkris%5CMiniconda3%5Clib%5Csite-packages%5Curllib3%5Cpackages%5Csix.py%22%2C%20line%20735%2C%20in%20reraise%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3Eraise%20value%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3EFile%20%22C%3A%5CUsers%5Csubkris%5CMiniconda3%5Clib%5Csite-packages%5Curllib3%5Cconnectionpool.py%22%2C%20line%20670%2C%20in%20urlopen%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3Ehttplib_response%20%3D%20self._make_request(%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3EFile%20%22C%3A%5CUsers%5Csubkris%5CMiniconda3%5Clib%5Csite-packages%5Curllib3%5Cconnectionpool.py%22%2C%20line%20428%2C%20in%20_make_request%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3Eself._raise_timeout(err%3De%2C%20url%3Durl%2C%20timeout_value%3Dread_timeout)%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3EFile%20%22C%3A%5CUsers%5Csubkris%5CMiniconda3%5Clib%5Csite-packages%5Curllib3%5Cconnectionpool.py%22%2C%20line%20335%2C%20in%20_raise_timeout%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3Eraise%20ReadTimeoutError(%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3Eurllib3.exceptions.ReadTimeoutError%3A%20HTTPConnectionPool(host%3D'localhost'%2C%20port%3D5000)%3A%20Read%20timed%20out.%20(read%20timeout%3D5)%3C%2FEM%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3EDuring%20handling%20of%20the%20above%20exception%2C%20another%20exception%20occurred%3A%3C%2FEM%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3ETraceback%20(most%20recent%20call%20last)%3A%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3EFile%20%22C%3A%5CUsers%5Csubkris%5CMiniconda3%5Clib%5Crunpy.py%22%2C%20line%20194%2C%20in%20_run_module_as_main%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3Ereturn%20_run_code(code%2C%20main_globals%2C%20None%2C%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3EFile%20%22C%3A%5CUsers%5Csubkris%5CMiniconda3%5Clib%5Crunpy.py%22%2C%20line%2087%2C%20in%20_run_code%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3Eexec(code%2C%20run_globals)%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3EFile%20%22c%3A%5CUsers%5Csubkris%5C.vscode%5Cextensions%5Cms-python.python-2021.1.502429796%5CpythonFiles%5Clib%5Cpython%5Cdebugpy%5C__main__.py%22%2C%20line%2045%2C%20in%20%3CMODULE%3E%3C%2FMODULE%3E%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3Ecli.main()%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3EFile%20%22c%3A%5CUsers%5Csubkris%5C.vscode%5Cextensions%5Cms-python.python-2021.1.502429796%5CpythonFiles%5Clib%5Cpython%5Cdebugpy%2F..%5Cdebugpy%5Cserver%5Ccli.py%22%2C%20line%20444%2C%20in%20main%20%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3Erun()%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3EFile%20%22c%3A%5CUsers%5Csubkris%5C.vscode%5Cextensions%5Cms-python.python-2021.1.502429796%5CpythonFiles%5Clib%5Cpython%5Cdebugpy%2F..%5Cdebugpy%5Cserver%5Ccli.py%22%2C%20line%20285%2C%20in%20run_file%20runpy.run_path(target_as_str%2C%20run_name%3Dcompat.force_str(%22__main__%22))%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3EFile%20%22C%3A%5CUsers%5Csubkris%5CMiniconda3%5Clib%5Crunpy.py%22%2C%20line%20265%2C%20in%20run_path%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3Ereturn%20_run_module_code(code%2C%20init_globals%2C%20run_name%2C%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3EFile%20%22C%3A%5CUsers%5Csubkris%5CMiniconda3%5Clib%5Crunpy.py%22%2C%20line%2097%2C%20in%20_run_module_code%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3E_run_code(code%2C%20mod_globals%2C%20init_globals%2C%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3EFile%20%22C%3A%5CUsers%5Csubkris%5CMiniconda3%5Clib%5Crunpy.py%22%2C%20line%2087%2C%20in%20_run_code%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3Eexec(code%2C%20run_globals)%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3EFile%20%22c%3A%5CLearning%5CPython_Trials%5Ccall_service.py%22%2C%20line%2017%2C%20in%20%3CMODULE%3E%3C%2FMODULE%3E%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3Eresponse%20%3D%20requests.post(url%2C%20json%3Dpayload%2C%20timeout%3D5)%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3EFile%20%22C%3A%5CUsers%5Csubkris%5CMiniconda3%5Clib%5Csite-packages%5Crequests%5Capi.py%22%2C%20line%20119%2C%20in%20post%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3Ereturn%20request('post'%2C%20url%2C%20data%3Ddata%2C%20json%3Djson%2C%20**kwargs)%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3EFile%20%22C%3A%5CUsers%5Csubkris%5CMiniconda3%5Clib%5Csite-packages%5Crequests%5Capi.py%22%2C%20line%2061%2C%20in%20request%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3Ereturn%20session.request(method%3Dmethod%2C%20url%3Durl%2C%20**kwargs)%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3EFile%20%22C%3A%5CUsers%5Csubkris%5CMiniconda3%5Clib%5Csite-packages%5Crequests%5Csessions.py%22%2C%20line%20530%2C%20in%20request%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3Eresp%20%3D%20self.send(prep%2C%20**send_kwargs)%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3EFile%20%22C%3A%5CUsers%5Csubkris%5CMiniconda3%5Clib%5Csite-packages%5Crequests%5Csessions.py%22%2C%20line%20643%2C%20in%20send%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3Er%20%3D%20adapter.send(request%2C%20**kwargs)%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3EFile%20%22C%3A%5CUsers%5Csubkris%5CMiniconda3%5Clib%5Csite-packages%5Crequests%5Cadapters.py%22%2C%20line%20529%2C%20in%20send%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3Eraise%20ReadTimeout(e%2C%20request%3Drequest)%3C%2FEM%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CEM%3Erequests.exceptions.ReadTimeout%3A%20HTTPConnectionPool(host%3D'localhost'%2C%20port%3D5000)%3A%20Read%20timed%20out.%20(read%20timeout%3D5)%3C%2FEM%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWithout%20using%20timeout%20attribute%2C%20the%20code%20gets%20stuck%20at%20the%20request%20line.%3C%2FP%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2114920%22%20slang%3D%22en-US%22%3ERe%3A%20Unable%20to%20access%20brain%20deployed%20in%20docker%20using%20python%20script%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2114920%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F955928%22%20target%3D%22_blank%22%3E%40smartsubbu%3C%2FA%3E%26nbsp%3BThanks%20for%20posting%20the%20question.%20I%20don't%20see%20anything%20obviously%20wrong%20with%20your%20Python%20code%2C%20but%20there%20must%20be%20some%20relevant%20difference%20between%20the%20postman%20query%20and%20the%20Python%20query.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20noticed%20that%20the%20postman%20query%20says%20%22Method%20Get%2FPost%22%2C%20so%20I'm%20not%20sure%20which%20of%20those%20two%20methods%20was%20used.%20Exported%20brains%20support%20both%20get%20and%20post%2C%20but%20%22post%22%20is%20the%20preferred%20method%2C%20and%20%22get%22%20is%20deprecated%20(although%20still%20theoretically%20supported).%20Could%20you%20try%20changing%20your%20Python%20code%20to%20use%20%22post%22%20instead%3F%20I%20recommend%20restarting%20your%20brain%20container%20before%20you%20try%20sending%20it%20a%20new%20request.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20the%20%22post%22%20doesn't%20work%2C%20then%20the%20next%20step%20is%20to%20look%20more%20deeply%20at%20how%20the%20postman%20query%20differs%20form%20the%20query%20sent%20via%20Python.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B-Eric%3C%2FP%3E%3C%2FLINGO-BODY%3E%3C%2FLINGO-BODY%3E
Microsoft

I imported exported brain from azure as Docker image.

Ran the container.

Verified the webservice in postman.  Obtained the response.

URL: http://localhost:5000/v1/prediction
Method: Get/Post
Sample Request body:
{
"x_position": 0.31,
"x_velocity": 0.07,
"angle_position": 11.3,
"angle_velocity": 0.8
}

Sample Response:
{
"command": 1.0
}

 

But on calling the endpoint using python code, the program is stuck with no response. Code as follows:

>>> import requests
>>> endpoint = "http://localhost:5000/v1/prediction"
>>> state = {
... "x_position": 0.31,
... "x_velocity": 0.07,
... "angle_position": 11.3,
... "angle_velocity": 0.8
... }
>>> requests.get(endpoint, json=state)

14 Replies

@smartsubbu Thanks for posting the question. I don't see anything obviously wrong with your Python code, but there must be some relevant difference between the postman query and the Python query.

 

I noticed that the postman query says "Method Get/Post", so I'm not sure which of those two methods was used. Exported brains support both get and post, but "post" is the preferred method, and "get" is deprecated (although still theoretically supported). Could you try changing your Python code to use "post" instead? I recommend restarting your brain container before you try sending it a new request.

 

If the "post" doesn't work, then the next step is to look more deeply at how the postman query differs form the query sent via Python.

 

 -Eric

@erictr Thanks for your suggestions.  I have already tried both get and post, but tried again today.  

1. Restarted the container.

2. Verified again in postman with Post method - Pass

3. Ran a python code with Post method and including a header

 

import requests

url = "http://localhost:5000/v1/prediction"
payload={
"x_position": 0.31,
"x_velocity": 0.07,
"angle_position": 11.3,
"angle_velocity": 0.8
}
headers = {
  'Content-Type': 'application/json'
}
print("B4 request")
response = requests.post(url, json=payload, timeout=5)
print(response.text)
print("End of program")
 
with the timeout attribute, I get the following error

B4 request
Traceback (most recent call last):
File "C:\Users\subkris\Miniconda3\lib\site-packages\urllib3\connectionpool.py", line 426, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File "C:\Users\subkris\Miniconda3\lib\site-packages\urllib3\connectionpool.py", line 421, in _make_request
httplib_response = conn.getresponse()
File "C:\Users\subkris\Miniconda3\lib\http\client.py", line 1332, in getresponse
response.begin()
File "C:\Users\subkris\Miniconda3\lib\http\client.py", line 303, in begin
version, status, reason = self._read_status()
File "C:\Users\subkris\Miniconda3\lib\http\client.py", line 264, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "C:\Users\subkris\Miniconda3\lib\socket.py", line 669, in readinto
return self._sock.recv_into(b)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\subkris\Miniconda3\lib\site-packages\requests\adapters.py", line 439, in send
resp = conn.urlopen(
File "C:\Users\subkris\Miniconda3\lib\site-packages\urllib3\connectionpool.py", line 726, in urlopen
retries = retries.increment(
File "C:\Users\subkris\Miniconda3\lib\site-packages\urllib3\util\retry.py", line 410, in increment
raise six.reraise(type(error), error, _stacktrace)
File "C:\Users\subkris\Miniconda3\lib\site-packages\urllib3\packages\six.py", line 735, in reraise
raise value
File "C:\Users\subkris\Miniconda3\lib\site-packages\urllib3\connectionpool.py", line 670, in urlopen
httplib_response = self._make_request(
File "C:\Users\subkris\Miniconda3\lib\site-packages\urllib3\connectionpool.py", line 428, in _make_request
self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
File "C:\Users\subkris\Miniconda3\lib\site-packages\urllib3\connectionpool.py", line 335, in _raise_timeout
raise ReadTimeoutError(
urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='localhost', port=5000): Read timed out. (read timeout=5)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\subkris\Miniconda3\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\subkris\Miniconda3\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "c:\Users\subkris\.vscode\extensions\ms-python.python-2021.1.502429796\pythonFiles\lib\python\debugpy\__main__.py", line 45, in <module>
cli.main()
File "c:\Users\subkris\.vscode\extensions\ms-python.python-2021.1.502429796\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 444, in main
run()
File "c:\Users\subkris\.vscode\extensions\ms-python.python-2021.1.502429796\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 285, in run_file runpy.run_path(target_as_str, run_name=compat.force_str("__main__"))
File "C:\Users\subkris\Miniconda3\lib\runpy.py", line 265, in run_path
return _run_module_code(code, init_globals, run_name,
File "C:\Users\subkris\Miniconda3\lib\runpy.py", line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "C:\Users\subkris\Miniconda3\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "c:\Learning\Python_Trials\call_service.py", line 17, in <module>
response = requests.post(url, json=payload, timeout=5)
File "C:\Users\subkris\Miniconda3\lib\site-packages\requests\api.py", line 119, in post
return request('post', url, data=data, json=json, **kwargs)
File "C:\Users\subkris\Miniconda3\lib\site-packages\requests\api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\subkris\Miniconda3\lib\site-packages\requests\sessions.py", line 530, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\subkris\Miniconda3\lib\site-packages\requests\sessions.py", line 643, in send
r = adapter.send(request, **kwargs)
File "C:\Users\subkris\Miniconda3\lib\site-packages\requests\adapters.py", line 529, in send
raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPConnectionPool(host='localhost', port=5000): Read timed out. (read timeout=5)

 

Without using timeout attribute, the code gets stuck at the request line.

There's clearly something different about postman and the Python `requests` library are formulating the HTTP query. We need to figure out what's going wrong with the latter.

 

Can you confirm that you added the headers to the request? In your sample below, you define `headers`, but you don't pass it in to post call. I don't think that should matter because the documentation for `requests` says that if you pass an argument to the `json` parameter, the `Content-Type` will be set to `application/json` automatically.

 

Another thought is to include the header _and_ manually encode the json payload to ensure that it's properly formed. That way, you can print it out and examine it before it's sent.

```python

json_payload = json.dumps(payload)

print(json_payload)

response = requests.post(url, data=json_payload, headers=headers)

```

 

Another idea is to modify the URL to "http://localhost:5000/v1/dummy" to see if you receive an error or a hang. That will tell us whether you're reaching the HTTP server within the container.

 

 -Eric

@erictr 

I was making several changes and forgot to include header.  But adding the header made no difference.  I changed the code to try other options you suggested

 

import requests
import json

#url = "http://localhost:5000/v1/prediction"
url = "http://localhost:5000/v1/dummy"

payload={
"x_position": 0.31,
"x_velocity": 0.07,
"angle_position": 11.3,
"angle_velocity": 0.8
}
json_payload = json.dumps(payload)
print(json_payload)

headers = {
  'Content-Type': 'application/json'
}

print("B4 request")

response = requests.post(url, data=json_payload, headers=headers)
print(response.text)
print("End of program")
 
Still stuck at the requests line whether correct url or dummy url is specified.  Looks like its not even hitting the endpoint:port
 
{"x_position": 0.31, "x_velocity": 0.07, "angle_position": 11.3, "angle_velocity": 0.8}
B4 request

@erictr The same python code works if I deploy in cloud in a acr and use the azurewebsites.net/v1/prediction url. 

 

{"x_position": 0.31, "x_velocity": 0.07, "angle_position": 11.3, "angle_velocity": 0.8}
B4 request
{"command":1.0}
End of program

@smartsubbu Here's another suggestion from another engineer on our team.

 

Try running:

```

curl -v http::/localhost:5000/v1/status
```
 
If that works, try:
```
curl -v -H "Content-Type: application/json" -d '{"x_position": 0.31, "x_velocity": 0.07, "angle_position": 11.3, "angle_velocity": 0.8}' http://localhost:5000/v1/prediction
```
best response confirmed by smartsubbu (Microsoft)
Solution

Hi @smartsubbu,

 

Do you see this same freezing behavior with a local container only after trying to run it with postman, or regardless of whether you've run with postman or not?  A quick test would be to restart the export brain container then try to access it with either curl or your python script as it's first request.

 

@erictr I tried the first curl command.  After waiting around 10mins gave up.  Its stuck with this message

 

* Trying 127.0.0.1:5000...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 5000 (#0)
> GET /v1/status HTTP/1.1
> Host: localhost:5000
> User-Agent: curl/7.68.0
> Accept: */*
>

 

Even tried the second command and waited for 5 mins.  No response after this message

* Trying 127.0.0.1:5000...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 5000 (#0)
> POST /v1/prediction HTTP/1.1
> Host: localhost:5000
> User-Agent: curl/7.68.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 87
>
* upload completely sent off: 87 out of 87 bytes

@chetand I never thought of this.  As you mentioned, I restarted the container and ran both my python program and curl command in bash without verifying in Postman.  Both worked fine.  

 

Curl output:

> --header 'Content-Type: application/json' \
> --data-raw '{
> "x_position": 0.31,
> "x_velocity": 0.07,
> "angle_position": 7.3,
> "angle_velocity": 0.8
> }'
{"command":1.0}

 

Any idea, why running in postman would be creating an issue.  Is it blocking all other connections?

@smartsubbu That's good news!

 

We've found that postman adds a "keep-alive" header by default, and that's what causes this behavior. IIRC, there's a setting in postman to not specify this header.

 

 

Hi @smartsubbu

 

If you do in postman first, wait for 10 minutes and try the curl does it repro?  

The error messages returned are not trivial.
I'm a bit out of the loop however in the error message we are given some help with the following:
B4 request
Traceback (most recent call last):
File "C:\Users\subkris\Miniconda3\lib\site-packages\urllib3\connectionpool.py", line 426, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File "C:\Users\subkris\Miniconda3\lib\site-packages\urllib3\connectionpool.py", line 421, in _make_request
httplib_response = conn.getresponse()
File "C:\Users\subkris\Miniconda3\lib\http\client.py", line 1332, in getresponse
response.begin()
File "C:\Users\subkris\Miniconda3\lib\http\client.py", line 303, in begin
version, status, reason = self._read_status()
File "C:\Users\subkris\Miniconda3\lib\http\client.py", line 264, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")

A string represents alphanumeric data. This means that a string can contain many different characters, but they are all considered as if they were text, even if the characters are numbers.

Let's continue...

File "C:\Users\subkris\Miniconda3\lib\socket.py", line 669, in readinto
return self._sock.recv_into(b)
socket.timeout: timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\subkris\Miniconda3\lib\site-packages\requests\adapters.py", line 439, in send
resp = conn.urlopen(
File "C:\Users\subkris\Miniconda3\lib\site-packages\urllib3\connectionpool.py", line 726, in urlopen
retries = retries.increment(
File "C:\Users\subkris\Miniconda3\lib\site-packages\urllib3\util\retry.py", line 410, in increment
raise six.reraise(type(error), error, _stacktrace)

So then the error is of a data type.
It's looking like the data being returned to instruct your program to increment trying the url is not returning the data in the expected type, it recieving a string and it wants an integer... and it is...

Iline = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")

So then its a data type that's of the incorrect form ....

@erictr That's great.  I verified myself, disabling that hidden header and running in postman.  Now python code is also able to access.  Thanks for figuring out the root cause.

@Kinshuman Thanks for your suggestion.  I have tried waiting for 10 mins, but have waited for 5 mins several times.  But by verifying other recommendations/suggestions in this thread, the root cause is postman trying to keep the connection alive after a request.  With that header disabled, it works parallelly in both python and postman.