Problems with School Proxy by using MQTT protocol

Hi all,

Now I am doing a project of MQTT protocol by using Arduino. I have an Arduino board and an Arduino Ethernet Shield. I use the ethernet shield to connect to Internet and the shield is connected to a net wire in my school. A proxy server is set in my school so everyone need to make proxy settings to connect outside networks. It's same to Arduino board. When I use the sample file of MQTT library, I need to modify the code. My code is below:

#include <PubSubClient.h>
#include <SPI.h>
#include <Ethernet.h>

// Update these with values suitable for your network.
byte mac[]    = {  0x90, 0xA2, 0xDA, 0x0D, 0xF2, 0x45 };
byte server[] = { 212, 72, 74, 21 }; //MQTT dashboard
//byte ip[]     = { 172, 16, 0, 100 };
byte proxy[] = { 10, 204, 18, 202 }; // School Proxy

void callback(char* topic, byte* payload, unsigned int length) 
{
  // handle message arrived
}

EthernetClient ethClient;
PubSubClient arduino(server, 1883, callback, ethClient);

void setup()
{
  Ethernet.begin(mac);
  Serial.begin(9600);
  Serial.println("connecting...");
  Serial.println();
  delay(500);
  int eth=0;
  while (eth==0)
  {
    Serial.println("Proxy Connecting...");
    eth = ethClient.connect(proxy, 3128);
  }
  Serial.println("Proxy Connected!");
  Serial.println();
  
  while ((arduino.connect("niunai1221"))==0)
  {
    Serial.println("MQTT Connecting...");
    delay(1000);
  }
  Serial.println("MQTT Connected!");
  arduino.publish("outTopic1221","hello world");
}

void loop()
{
  arduino.loop();
}

The code ethClient.connect(proxy, 3128) could connect Arduino to school proxy successfully, but after that, code arduino.connect("niunai1221") didn't work.

I am not a English speaker, hope everyone could understand my words. Waiting for your reply~

Anybody here?

=(

I don't see anything in the arduino ethernet docs about dealing with a proxy.

I'd suggest that you either do your testing in a different environment without a proxy, or see if you can plug your arduino into something 'upstream' of the proxy and get access to the internet without it.