Giter VIP home page Giter VIP logo

Comments (21)

lylepratt avatar lylepratt commented on May 17, 2024

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.

Marak avatar Marak commented on May 17, 2024

Should be fixed in production now.

Small copy / paste error from a refactor.

Commit coming.

from hook.io.

lylepratt avatar lylepratt commented on May 17, 2024

thanks!

from hook.io.

lylepratt avatar lylepratt commented on May 17, 2024

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.

Marak avatar Marak commented on May 17, 2024

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.

lylepratt avatar lylepratt commented on May 17, 2024

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.

lylepratt avatar lylepratt commented on May 17, 2024

OK, I'm a dummy. I just realized that hook.params pre-parses the JSON for you.

from hook.io.

Marak avatar Marak commented on May 17, 2024

It's okay!

I'd recommend reading the docs from start to finish, it's not that long and should help.

http://hook.io/docs

http://hook.io/docs#hook

from hook.io.

lylepratt avatar lylepratt commented on May 17, 2024

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.

Marak avatar Marak commented on May 17, 2024

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> &nbsp; &nbsp;at Object.parse (native)<br> &n
bsp; &nbsp;at parse (/home/ubuntu/hook.io/node_modules/body-parser/lib/types/jso
n.js:76:17)<br> &nbsp; &nbsp;at /home/ubuntu/hook.io/node_modules/body-parser/li
b/read.js:98:18<br> &nbsp; &nbsp;at IncomingMessage.onEnd (/home/ubuntu/hook.io/
node_modules/body-parser/node_modules/raw-body/index.js:136:7)<br> &nbsp; &nbsp;
at IncomingMessage.g (events.js:199:16)<br> &nbsp; &nbsp;at IncomingMessage.emit
 (events.js:104:17)<br> &nbsp; &nbsp;at _stream_readable.js:898:16

from hook.io.

lylepratt avatar lylepratt commented on May 17, 2024

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.

Marak avatar Marak commented on May 17, 2024

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.

lylepratt avatar lylepratt commented on May 17, 2024

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.

Marak avatar Marak commented on May 17, 2024

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.

lylepratt avatar lylepratt commented on May 17, 2024

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.

Marak avatar Marak commented on May 17, 2024

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.

Marak avatar Marak commented on May 17, 2024

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.

Marak avatar Marak commented on May 17, 2024

Hey, related issue!

mschema/mschema#9

We found it!

from hook.io.

lylepratt avatar lylepratt commented on May 17, 2024

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.

Marak avatar Marak commented on May 17, 2024

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.

lylepratt avatar lylepratt commented on May 17, 2024

Good on my end. Thanks for your help and speedy responses!

from hook.io.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.