PubSubClient EthernetClient port 1883 , 80 simultaneously

Hello

I need this

  1. Open a channel to the MQTT server 192.168.88.50 where receive and transmit information (constantly)

  2. Every five seconds to connect with the address 192.168.88.200 and make a call on HTTP port 80

The problem is that the second connection always fails, maybe I have to close MQTT open HTTP?

or is there another solution?

//=========================================================================
// PROGRAM VAR - CONST
//=========================================================================
#include <SPI.h>                      //
#include <Ethernet.h>                 //
#include <PubSubClient.h>             //
#include <ArduinoJson.h>              //
unsigned int count = 0;               //
char rqs[6] = "00000";                // IOT requester iD
char *topic;                          // Topic Var
const int MAX_STRING_LEN = 128 ;      // The largest string you will process
char strBuf[MAX_STRING_LEN];          // Static buffer for computation
char inData[MAX_STRING_LEN];          // Allocate some space for the string
//=========================================================================
#define Alive 0                       // The alive id for incoming request
char aliveMsg[8] = "";                // Alive msg
//=========================================================================
char msgAuth[20];
char *y;
int pointer = -1;
int insertSql = -1;
//=========================================================================
char EndSend[3]   = "*E";             //
char Empty[1]     = "";               //
char str_float[6];                    // Static buffer for float to char conversion
char *dtostrf(double val, signed char width, unsigned char prec, char *s);
//*************************************************************************
// Update these with values suitable for your network.
//*************************************************************************
byte iotMac[]     = { 0x90, 0xA2, 0xDA, 0x0D, 0x82, 0x39 };// iot mac Uno
byte iotIp[]      = { 192, 168, 88, 252};                   // iot ip
byte iotGateway[] = { 192, 168, 88, 1 };                    // iot Gateway
byte iotDns[]     = { 192, 168, 88, 1 };                    // iot dns
byte iotSubnet[]  = { 255, 255, 255, 0};                      // iot subnet
//*************************************************************************
// MQTT dataino Ip
//*************************************************************************
byte server[]     = { 192, 168, 88, 50 }; 
char userName[] = "xxx";                   // Reserved do not divulgate
char password[] = "xxxxxxx";             // Reserved do not divulgate
//*************************************************************************
// Project and iot iD values
//*************************************************************************
char ProjectTopic[15] = "3062-4818-5961";                   // Project iD
char IOT[6]           = "v2r30";                            // IOT iD
char IotTopic[21]     = "3062-4818-5961/v2r30"; // Channel iot
//=========================================================================
//
//=========================================================================
EthernetClient ethClient;
PubSubClient client( server, 1883, callback, ethClient );
//*************************************************************************
// LTE Init
//*************************************************************************
IPAddress LTE( 192, 168, 88, 200 ); // numeric IP
unsigned long start = millis();

void setup()
{
  // Openf serial communications:
  Serial.begin( 57000 );
  // start the Ethernet connection:
  Ethernet.begin( iotMac, iotIp, iotDns, iotGateway, iotSubnet );
  Serial.println( );
  delay( 1000 );
  Serial.println( F( "MQTT Connecting..." ) );
  //-----------------------------------------------------------------------
  // Check if MQTT is connect
  //-----------------------------------------------------------------------
  if ( client.connect(IOT, userName, password )) {
    subscribeChannels();
  } else {
    Serial.println( F( "MQTT ERROR" ) );
  }
}
//=========================================================================
//
//=========================================================================
void loop()
{

  // ************************************************************************
  // **                                                                    **
  // ************************************************************************
  if ( millis() - start > 5000 ) {

    start = millis();

    // ************************************************************************
    // **                                                                    **
    // ************************************************************************


    // if you get a connection, report back via serial:
    if ( ethClient.connect( LTE, 80) ) {
      // Make a HTTP request:
      Serial.println( "HTTP Connecting..." );
      ethClient.println( F( "GET /test.php?data=1&cmd=sig HTTP/1.1" ) );
      ethClient.println( F( "Host: 192.168.0.1" ) );
      ethClient.println( F( "Connection: close" ));
      ethClient.println();
    } else {
      // if you didn't get a connection to the server:
      Serial.println( F("HTTP failed") );
    }
  }
  //=========================================================================
  //
  //=========================================================================
  if (!client.loop()) {
    Serial.print( F( "MQTT disconnected..." ) );
    if ( client.connect( IOT, userName, password ) ) {
      Serial.println( F ( "MQTT reconnected." ) );
      subscribeChannels();
    } else {
      Serial.println( F( "MQTT failed.") );
    }
  }

}
//=========================================================================
//
//=========================================================================
void subscribeChannels()
{
  Serial.print( F( "Connected As:" ) );
  Serial.println( IOT );

  client.subscribe( ProjectTopic );
  Serial.print( F( "subscribe:" ) );
  Serial.println( ProjectTopic );

  client.subscribe( IotTopic );
  Serial.print( F( "subscribe:" ) );
  Serial.println( IotTopic );

  sprintf( aliveMsg, "%s;!", IOT );
  client.publish( ProjectTopic , aliveMsg );
  Serial.println( F( "I'm Alive !" ) );
}
//*************************************************************************
//
//*************************************************************************
void callback( char* topicIn, byte * payload, unsigned int length ) {
  // handle message arrived
  topic = topicIn;
  Serial.print( F( "payload:" ) );
  for ( unsigned int i = 0 ; i < length ; i++ ) {
    Serial.print( char( payload[i] ) );
    inData[i] = char( payload[i] );
  }// End For
  Serial.println( );
  // Clear inData Array
  for (int i = 0 ; i < MAX_STRING_LEN ; i++ ) {
    inData[i] = 0;
  }// End For
}

You didn't post enough of your code. It is best to post all your code, and use code tags please.

  1. Every five seconds to connect with the address 192.168.88.200
      ethClient.println( F( "Host: 192.168.0.1" ) );

That doesn’t look like 192.128.88.200.

Unless you are hosting multiple domains, like godaddy.com, you don’t need a Host directive.

  Serial.begin( 57000 );

That’s not a standard speed. What are you talking to?