Code Monkey home page Code Monkey logo

Comments (6)

twisted1919 avatar twisted1919 commented on August 17, 2024 1

Maybe you should use createUpdate instead of create and don't call deleteByEmail anymore, so try that and see how it goes.

On another note, Mailwizz does check for dupes, but somehow your request is multiplied at the same time and therefore is too fast for mailwizz to catch it for some reason, i assume mainly because the database check for dupes takes too long. You might wanna look at https://kb.mailwizz.com/articles/performance-improvements/ or try to see why the post request gets multiplied, as mailwizz doesn't do this.

from mailwizz-php-sdk.

twisted1919 avatar twisted1919 commented on August 17, 2024

Do you have any email verification service enabled ?

from mailwizz-php-sdk.

rayliverified avatar rayliverified commented on August 17, 2024

No.

I did some more testing and I believe I have isolated the reason for the problem.
I am calling the MailWizz API in a POST request and for some reason, the POST request is executed multiple times. The POST request is only called once, but the server executes it multiple times which is why the MailWizz API is adding the same email multiple times. When the MailWizz request is removed from the POST request, the POST request only executes once.

I do not know why MailWizz would cause a POST request to repeat. This seems like a separate issue.

The issue here is that MailWizz adds an email even when it already exists.

My post request:

<?php
if (!empty($_POST)) {

    $email = isset($_POST['email']) ? $_POST['email'] : '';

    $email = helper::clearText($email);
    $email = helper::escapeText($email);

    $result = array();
    $result = $helper->isEmailExistsInfo($email);

    if ($result['error'] !== false)
    {
        //MailWizz
        require_once dirname(__FILE__) . '/mailwizz.init.php';
        $endpoint = new MailWizzApi_Endpoint_ListSubscribers();
        //Delete user if exists in list so user can be added again.
        $endpoint->deleteByEmail('wj730zl99w074', $email);
        //App New Users
        $response = $endpoint->create('wj730zl99w074', array(
            'EMAIL'    => $email
        ));
    }

    echo json_encode($result);
    exit;
}

from mailwizz-php-sdk.

rayliverified avatar rayliverified commented on August 17, 2024

I did some more research and it looks like 90% of the issue is because my client is retrying the POST request due to timeout which is why the POST request is being called multiple times. However, the max number of retries is 1 which means at most, the email should only be added twice.

There are instances where emails have been added 3 times. Could the internal HttpClient used by MailWizz have a retry timeout too? See this StackOverflow for a description of the default behavior of HttpClient: https://stackoverflow.com/questions/23054289/httpclient-executes-requests-multiple-time-if-request-timed-out

Thanks for the help!

from mailwizz-php-sdk.

twisted1919 avatar twisted1919 commented on August 17, 2024

The client we're using in the code does not do any retry.

from mailwizz-php-sdk.

rayliverified avatar rayliverified commented on August 17, 2024

Ok, good to know. I think I've solved the issue by setting retry to 0 in the client. If I get anymore duplicates, I'll reopen this issue for further investigation. Thanks for the help!

from mailwizz-php-sdk.

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.