• Resolved kartboy16

    (@kartboy16)


    On my production WordPress site, when I try to post via the REST API and the post is over 852 characters, I get Error: socket hang up. If it’s 852 characters or less, it posts.

    This only happens when I post from my Meteor Cloud Server. I don’t have this issue posting from my local machine. I also pulled the production site to a staging server and do not have this issue. So it only comes up when posting from my Meteor Cloud Server to the Production WordPress Site

    I tried:

    created .user.ini and added post_max_size = 64M
    Whitelisted IPs on Wordfence
    Turned off plugins
    Updated Theme
    Godaddy – no issue they can see
    Set Header Content-Length

    const result = await wp.posts()
                    .setHeaders({
                        'Content-Type': 'application/json',
                        Authorization: Bearer myToken,
                        'Content-Length': JSON.stringify(postValues).length,
                    })
                    .create(JSON.stringify(postValues));
    • This topic was modified 3 years, 6 months ago by kartboy16.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @kartboy16! It’s possible these requests are taking longer to route through to the Meteor Cloud Server, which might be why they’re timing out. This post has some suggestions on how to increase the timeout for WPAPI requests: https://github.com/WP-API/node-wpapi/issues/441

    Can you try that approach and see if the request eventually resolves or if you get the same socket hang up error?

    Thread Starter kartboy16

    (@kartboy16)

    @aetherunbound Thanks for the suggestion. It may be an issue with the version of node-wpapi i’m using. I ended up calling the endpoint using fetch and it worked!

    Fantastic! If your question has been answered, we would love if you would mark this topic as resolved in the sidebar. This helps our volunteers find the topics that still need attention and more people will get helped, possibly like you did.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘REST API post times out when content is too large’ is closed to new replies.