Comments (21)
I also get the same error when I try to use it with the hook I am working on:
curl -H "Content-Type: application/json" -d '{"test": "fest", "ok": 1}' https://hook.io/lylepratt/bettervoice-calls-to-followupboss-events
Returns:
Error communicating with worker 10003
Error: socket hang up
at createHangUpError (_http_client.js:210:15)
at Socket.socketOnEnd (_http_client.js:288:23)
at Socket.emit (events.js:129:20)
at _stream_readable.js:898:16
from hook.io.
Should be fixed in production now.
Small copy / paste error from a refactor.
Commit coming.
from hook.io.
thanks!
from hook.io.
Can you point me in the right direction on how to access the raw POSTed data so I can parse the JSON? I see there is params object, but thats not what I need. Apologies if some of these are dumb questions. I'm a node.js n00b.
from hook.io.
You should try getting the hook working locally first if you can.
What posted data? You'll need to figure out how to make your http request and interact with the returned data.
Without any code, I don't really know what you are trying to do. Generally, you will either get back a string or a json object from making an http request...it depends which library / module / method / options you are using.
If you post a code example it would help.
from hook.io.
Hi Marak,
I'm working on this gist:
https://gist.github.com/lylepratt/76e491486df331a09a5f
I just want to parse any JSON posted to my hook. Sounds very simple, but nothing I have tried so far has worked. I'm not posting parameters, I'm posting raw data that I'm assuming I need to pass to JSON.parse
.
from hook.io.
OK, I'm a dummy. I just realized that hook.params pre-parses the JSON for you.
from hook.io.
It's okay!
I'd recommend reading the docs from start to finish, it's not that long and should help.
from hook.io.
I'm getting the same error again when sending in JSON. :(
curl -H "Content-Type: application/json" -d '{"from_number": "+15122651515", "contact_first_name": "Jimbo", "contact_last_name": null, "contact_email": "[email protected]", "audio_transcri"}' https://hook.io/lylepratt/bettervoice-calls-to-followupboss-events?key=48493eff638d94a1db63a39ecdd89d4649faf3
Error communicating with worker 10000
Error: socket hang up
at createHangUpError (_http_client.js:210:15)
at Socket.socketOnEnd (_http_client.js:288:23)
at Socket.emit (events.js:129:20)
at _stream_readable.js:898:16
from hook.io.
When I run that command I see this error:
$ curl -H "Content-Type: application/json" -d '{"from_number": "+15122651515",
"contact_first_name": "Jimbo", "contact_last_name": null, "contact_email": "jim
[email protected]", "audio_transcri"}' https://hook.io/lylepratt/bettervoice-calls-to
-followupboss-events?key=48493eff638d94a1db63a39ecdd89d4649faf3
SyntaxError: Unexpected token }<br> at Object.parse (native)<br> &n
bsp; at parse (/home/ubuntu/hook.io/node_modules/body-parser/lib/types/jso
n.js:76:17)<br> at /home/ubuntu/hook.io/node_modules/body-parser/li
b/read.js:98:18<br> at IncomingMessage.onEnd (/home/ubuntu/hook.io/
node_modules/body-parser/node_modules/raw-body/index.js:136:7)<br>
at IncomingMessage.g (events.js:199:16)<br> at IncomingMessage.emit
(events.js:104:17)<br> at _stream_readable.js:898:16
from hook.io.
Sorry, my paste got cut off some how. Here is the correct command:
curl -H "Content-Type: application/json" -d '{"from_number": "+15122651515", "contact_first_name": "Jimbo", "contact_last_name": null, "contact_email": "[email protected]", "audio_transcription": "This is a test voicemail"}' https://hook.io/lylepratt/bettervoice-calls-to-followupboss-events?key=48493eff638d94a1db63a39ecdd89d4649faf3
from hook.io.
Okay, nice one!
Looks like an issue with mschema. That is something we can write a test for and fix.
Try changing the null
value you are sending to an empty string.
curl -H "Content-Type: application/json" -d '{"from_number": "+15122651515", "contact_first_name": "Jimbo", "contact_last_name": "", "contact_email": "[email protected]", "audio_transcription": "This is a test voicemail"}' https://hook.io/lylepratt/bettervoice-calls-to-followupboss-events?key=48493eff638d94a1db63a39ecdd89d4649faf3
I ran the command a couple of times and I think it worked.
from hook.io.
Ahhh cool.
Yes, changing to String (or falsy boolean) both work. However, the problem is that the API that is sending the data in, sends a null
value if no last_name
(and for other values).
from hook.io.
You could add a 2-3 check in your hook to pre-process that data. It's not
pretty, but it will be quick and functional. You could also try setting a
default value of "" in the schema.
I'll have to take some time to review mschema to determine the best way to
gracefully handle this.
On Thu, Mar 5, 2015 at 5:42 AM, Lyle Pratt [email protected] wrote:
Ahhh cool.
Yes, changing to String (or falsy boolean) both work. However, the problem
is that the API that is sending the data in, sends a null value if no
last_name (and for other values).—
Reply to this email directly or view it on GitHub
#40 (comment).
from hook.io.
Ok. By preprocess, you mean remove it from the schema and manually validate it?
I can set a default value and change back to null before I send along to the FUB api.
from hook.io.
Ahh, I see. Maybe not.
I'm downloading node on this computer now to see how mschema behaves with null values for string types and any types. It's going to be a one-line fix somewhere.
I'm pretty sure you can figure out a work-around without us having to patch production. You could probably remove the field from the schema and access the incoming http object.
from hook.io.
Okay, I've reproduced the error in the following code:
var mschema = require('mschema');
var userSchema = {
"name": {
"type": "string",
},
"password": {
"type": "any",
}
}
var user = {
"name": null,
"password": null,
"email": "[email protected]"
}
// should validate true
console.log(mschema.validate(user, userSchema));
This is erroring out, which it should not. This needs to be fixed in mschema.
Usually, in the applications I build, if a key's value is null, I don't bother sending it over the wire in the first place.
Very nice catch. Thank you!
from hook.io.
Hey, related issue!
We found it!
from hook.io.
Hehe. Glad my many questions and stumbling around the world of node.js was actually helpful :) (and not completely annoying for you)
I've temporarily just commented out most of the schema fields in my hook for now and its working well:
https://gist.github.com/lylepratt/76e491486df331a09a5f
from hook.io.
Okay good.
I've got a working patch here for the mschema.
I could hot-patch server, but if you are working, it's better to wait for
next mschema release.
Should be able to get one out soon.
On Thu, Mar 5, 2015 at 6:05 AM, Lyle Pratt [email protected] wrote:
Hehe. Glad my many questions and stumbling around the world of node.js was
actually helpful :)I've temporarily just commented out most of the schema fields in my hook
for now and its working well:
https://gist.github.com/lylepratt/76e491486df331a09a5f—
Reply to this email directly or view it on GitHub
#40 (comment).
from hook.io.
Good on my end. Thanks for your help and speedy responses!
from hook.io.
Related Issues (20)
- Unable to see / create API keys on free accounts
- Monthly rate limits for January showing up as `0` instead of `01`
- Typo in the displayed text of the link to the microservice `/_admin/` page.
- hook.req.params not processed correctly sometimes HOT 1
- Seems cron not working since 2017-11-30T20:00:58.997Z HOT 1
- What is the current status of automated installation of npm modules on hook.io? HOT 1
- Allow ability for users to delete account / scrub data ( GDPR Compliance )
- Accented characters problem HOT 2
- Couchdb reference to deprecated image in Dockerfile
- Free CI in hub.docker.com to provide official images ?
- (2018-12-21) 500 Internal Server Error HOT 2
- Error HOT 3
- Not working locally HOT 4
- Site certificate outdated as of 2019-08-01 HOT 1
- Reset password
- Problem with service "message": "Rate limited: Max concurrency limit hit: 4" HOT 3
- Rate limited: Max concurrency limit hit: 4" HOT 1
- Wrong Content-Type of your websites
- docker-compose build fails with pywintypes.error (cannot find the file specified)
- hook.io seems unavailable
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hook.io.