I just started using Postman. I had this error «Error: socket hang up» when I was executing a collection runner. I’ve read a few post regarding socket hang up and it mention about sending a request and there’s no response from the server side and probably timeout. How do I extend the length of time of the request in Postman Collection Runner?
16 Answers
Socket hang up, error is port related error. I am sharing my experience. When you use same port for connecting database, which port is already in use for other service, then «Socket Hang up» error comes out.
eg:- port 6455 is dedicated port for some other service or connection. You cannot use same port (6455) for making a database connection on same server.
Sometimes, this error rises when a client waits for a response for a very long time. This can be resolved using the 202 (Accepted) Http code. This basically means that you will tell the server to start the job you want it to do, and then, every some-time-period check if it has finished the job.
If you are the one who wrote the server, this is relatively easy to implement. If not, check the documentation of the server you’re using.
Postman was giving «Could not get response» «Error: socket hang up».
I solved this problem by adding the Content-Length http header to my request
Are you using nodemon, or some other file-watcher? In my case, I was generating some local files, uploading them, then sending the URL back to my user. Unfortunately nodemon would see the «changes» to the project, and trigger a restart before a response was sent. I ignored the build directories from my file-watcher and solved this issue.
Here is the Nodemon readme on ignoring files: https://github.com/remy/nodemon#ignoring-files
I have just faced the same problem and I fixed it by close my VPN. So I guess that’s a network agent problem. You can check if you have some network proxy is on.
Socket hang up error could be due to the wrong URL of the API you are trying to access in the postman. please check the URL once carefully.
I solved this problem with disconnection my vpn. you should check if there is vpn connected.
this happaned when client wait for response for long time
try to sync your API requests from postman
then make login post and your are done
If Postman doesn’t get response within a specified time it will throw the error «socket hang up».
I was doing something like below to achieve 60 minutes of delay between each scenario in a collection:
get https://postman-echo.com/delay/10
pre request script :-
setTimeout(function(){}, [50000]);
I reduced time duration to 30 seconds:
setTimeout(function(){}, [20000]);
After that I stopped getting this error.
I had the same issue: «Error: socket hang up» when sending a request to store a file and backend logs mentioned a timeout as you described. In my case I was using mongoDB and the real problem was my collection’s array capacity was full. When I cleared the documents in that collection the error was dismissed. Hope this will help someone who faces a similar scenario.
It’s possible there are 2 things, happening at the same time.
- The url contains a port which is not commonly used AND
- you are using a VPN or proxy that does not support that port.
I had this problem. My server port was 45860 and I was using pSiphon anti-filter VPN. In that condition my Postman reported «connection hang-up» only when server’s reply was an error with status codes bigger than 0. (It was fine when some text was returning from server with no error code.)
When I changed my web service port to 8080 on my server, WOW, it worked! even though pSiphon VPN was connected.
Following on Abhay’s answer: double check the scheme. A server that is secured may disconnect if you call an https
endpoint with http
.
This happened to me while debugging an ASP.NET Core API running on localhost using the local cert. Took me a while to figure out since it was inside a Postman environment and also it was a Monday.
«Socket Hung Up» can be on-premise issue some time’s, because, of bottle neck in %temp% folder, try to free up the «temp» folder and give a try
I fixed this issue by disabling Postman token header.screenshot
What helped for me was replacing ‘localhost’ in the url to http://127.0.0.1 or whatever other address your local machine has assigned localhost to.
excel_zm Asks: How to add GeoJSON file to Leftlet map
I am new to JavaScript, HTML, and Leaflet. I would like to add a polygon to my Leaflet map.
I created a geojson file of two polygons (Will County, IL and Cook County, IL). I know the syntax is correct because I created it in FME and I can view it in FME and QGIS with the LL84 coordinate system. How do I add the geojson file to my html page?
Here is where I store the file. I want to use this file and don’t want to add thousands of coordinates to my html. This file is stored locally and I do not know if that is an issue. T:EYFP.geojson
Here is my HTML page. «»
// Initialize the map and set its view to Chicago var map = L.map(‘map’).setView([41.881832, -87.623177], 11);
var streetLayer = L.tileLayer(‘https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png’, { attribution: ‘© OpenStreetMap contributors’ });
streetLayer.addTo(map);
«»
Here is what the geojson file looks like. It has thousands of coordinates, but I’ve removed them (using BoundingBoxReplacer in FME) so I can paste them here. «»{ «type» : «FeatureCollection», «name» : «FP», «features» : [ { «type» : «Feature», «geometry» : { «type» : «Polygon», «coordinates» : [ [ [ -88.2635070004, 41.4695240004 ], [ -87.1111620005, 41.4695240004 ], [ -87.1111620005, 42.1542919999 ], [ -88.2635070004, 42.1542919999 ], [ -88.2635070004, 41.4695240004 ] ] ] }, «properties» : { «COUNTY» : «Cook County, IL», «OBJECTID» : 1 } }, { «type» : «Feature», «geometry» : { «type» : «Polygon», «coordinates» : [ [ [ -88.2614680002, 41.2015459998 ], [ -87.5255909999, 41.2015459998 ], [ -87.5255909999, 41.72893 ], [ -88.2614680002, 41.72893 ], [ -88.2614680002, 41.2015459998 ] ] ] }, «properties» : { «COUNTY» : «Will County, IL», «OBJECTID» : 2 } } ] }»»
SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, solveforum.
Я пытаюсь сделать запрос GET на какой-то сайт (не мой собственный сайт) через http-модуль узла.Яш версию 0.8.14. Вот мой код (CoffeeScript):
options =
host: 'www.ya.ru'
method: 'GET'
req = http.request options, (res) ->
output = ''
console.log 'STATUS: ' + res.statusCode
res.on 'data', (chunk) ->
console.log 'A new chunk: ', chunk
output += chunk
res.on 'end', () ->
console.log output
console.log 'End GET Request'
req.on 'error', (err) ->
console.log 'Error: ', err
req.end()
во время этой операции я получаю следующую ошибку: { [Ошибка: socket hang up] код: ‘ECONNRESET’ }. Если я прокомментирую обработчик ошибок, мое приложение завершится со следующей ошибкой:
events.js:48
throw arguments[1]; // Unhandled 'error' event
^
Error: socket hang up
at createHangUpError (http.js:1091:15)
at Socket.onend (http.js:1154:27)
at TCP.onread (net.js:363:26)
Я пытаюсь найти решение в интернете, но до сих пор не нашли их. Как решить эту проблему?
7 ответов
вы должны завершить запрос. Добавьте это в конце вашего скрипта:
req.end()
при использовании http.request()
, вы должны в какой-то момент вызов request.end()
.
req = http.request options, (res) ->
# ...
req.on 'error', # ...
req.end() # <---
до request
остается открытым, чтобы разрешить написании тело. И ошибка заключается в том, что сервер в конечном итоге сочтет соединение истекшим и закроет его.
кроме того, вы также можете использовать http.get()
С GET
запросы, которые будем называть .end()
автоматически начиная с GET
запросы обычно не ожидается, что тело.
15
автор: Jonathan Lonowski
в моем случае это был ‘Content-Length’ заголовок-я вытащил его, и теперь все в порядке…
код:
function sendRequest(data)
{
var options = {
hostname: host,
path: reqPath,
port: port,
method: method,
headers: {
'Content-Length': '100'
}
var req = http.request(options, callback);
req.end();
};
после удаления строки: ‘Content-Length’:’100′ он разобрался.
Я, наконец, обнаружил проблему и нашли решение. Проблема в том, что я использую прокси-сервер для подключения к интернету. Вот рабочий код:
options =
hostname: 'myproxy.ru'
path: 'http://www.ya.ru'
port: 3128
headers: {
Host: "www.ya.ru"
}
req = http.request options, (res) ->
output = ''
console.log 'STATUS: ' + res.statusCode
res.on 'data', (chunk) ->
console.log 'A new chunk: ', chunk
output += chunk
res.on 'end', () ->
console.log output
console.log 'End GET Request'
req.on 'error', (err) ->
console.log 'Error: ', err
req.end()
спасибо всем за помощь и предложения!
Я обнаружил, что это происходит в одном случае, когда я отправлял пустое тело, как — ‘{}’ в операции delete вызывается из интерн фреймворк для тестирования;
вместо этого я использовал null для отправки в качестве значения параметра body при выполнении запроса через
при обновлении с 0.10.33 до 0.12 nodejs эта ошибка была нажата.
в моем случае для запроса на удаление было тело (json). Ранее клиент узла устанавливал-‘ transfer — encoding ‘как chunked-по умолчанию, когда» content-length » не установлен. Кажется, в последней версии клиент узла перестал устанавливать передачу-кодирование по умолчанию.
Fix должен был установить его в запросе.
в моем случае, после обновления до node 8.0.0
пост не работает. добавление Content-Length
заголовок не помогает. Нужно добавить 'Connection': 'keep-alive'
до заголовок чтобы получить эту ошибку подальше.
let postOptions = {
method: 'POST',
form: form,
url: finalUrl,
followRedirect: false,
headers:{
'Connection': 'keep-alive'
}
};
request(postOptions, handleSAMLResponse);