Callback fails with 500 Internal Server error on iis - works on localhost

I have been working with a multi tab dash application for quite some time.
The application is running on a windows server through iis and flask.
I recently changed some of the pages.
Now on some of the callbacks I am getting the 500 Internal Server Error.
the callback that is falling makes a database call.

The callback works fine on localhost. Other callbacks in the application that reference the same database work fine.
The callback did not substantially change between this version and the one that worked yesterday. (I know I could have introduced a typo or something but this callback works fine on localhost.

Here is the callback that spits out the first error. There are errors on the other callbacks on this page because they do not have the data that this callback collects.

Output({‘type’: ‘status_values’,‘index’: ‘531’},“children”),
Output({‘type’: ‘trends_data’,‘index’: ‘531’},“children”),
Input({‘type’: ‘interval_timer’,‘index’: ‘531’},‘n_intervals’)

def update_historian531(countnum):

#-- Connect database -----
error_num = 0
head1 = ['tagname','value','timestamp']

  conn = PyADO.connect(None,host='computer',user='xxxx',password=xxxx'',provider='iHOLEDB.iHistorian.1')

#---- get status data -------

  cursCurrent = conn.cursor()

  cursCurrent.execute("SELECT tagname, value, timestamp FROM ihrawdata WHERE samplingmode=currentvalue \
    AND (tagname='SPD_ACTL' \
    or tagname='Hydraulic_Primary_PSI' \
    or tagname='HYDRAULIC_SECOND_PSI' \
    or tagname='DOWNTIME' \
    or tagname='ROLL_STATUS' \
   or tagname='HUB_STATUS' \
    or tagname='Firepolish_STATUS' \
    or tagname = 'TEMP' \
    or tagname = 'LOADER_STATUS' \
    or tagname='ERROR_CONDITION' \
   or tagname = 'IN_OUT') \
    AND criteriastring='#ONLYGOOD' \
        order by tagname " )

  result = cursCurrent.fetchall()
  df =pd.DataFrame(result)
  df.columns = head1

# -- end get status data --

#--- get trend data ----
  cursTrend10 = conn.cursor()

  cursTrend10.execute( "SELECT tagname, timestamp, value  FROM ihrawdata \
  WHERE (tagname = 'POLISHV' or \
   tagname ='TTR' or \
   tagname ='TAG' or \
   tagname ='SFP' or \
   tagname ='BLISTV' or \
   tagname ='WARP' or \
   tagname ='TAKE' or \
   tagname='PD_TRGT' or \
   tagname ='VISION' or \
   tagname ='INSPECT' or \
   tagname ='TRADE' or \
   tagname ='COUNT' or \
   tagname ='SHUTOFF') \
  AND samplingmode=lab \
  AND IntervalMilliseconds=1M \
  AND criteriastring='#ONLYGOOD' \
  AND timestamp between now - 3h and now ")
  #order by timestamp")

  resultTrend = cursTrend10.fetchall()
  headers = ['tagname','timestamp','value']
  dfTrend =pd.DataFrame(resultTrend)
  dfTrend.columns = headers
  dfTrend[["timestamp"]] = dfTrend[["timestamp"]].astype('datetime64[ns]')
#----- end get trend data
#---- end of process
  print('error occured')
  error_num = 1
  df = pd.DataFrame(columns = head1)
  dfTrend = pd.DataFrame(columns = head1)
return df.to_json(date_format='iso', orient='split'),  \
       dfTrend.to_json(date_format='iso', orient='split')

I also wonder if there is a limit on the iis server to the number of callbacks or some other limitation that exists on the iis server that I am now running up against that I was not before.

Thank you.

I broke the callback up into two separate callbacks, one for each output. Now the callback with the output ‘trends_data’ is working but the callback with the output ‘status_values’ is not working.

Again, it works fine in my test environment but not via IIS in production. I still get the 500 error on this callback only.

P.S. using the terminal tool on the browser is very helpful.

I found the problem with the code:
I did not convert the time stamp on the pandas dataframe created from the first database call.
I added the line

df[[“timestamp”]] = df[[“timestamp”]].astype(datetime64[ns]’) after the dataframe was created in the first database call.

Without this timestamp conversion the df.to_json(date_format=‘iso’, orient=‘split’) line on the return statement fails in my production environment.

It is interesting that it does not fail on my PC when I run the application locally. No error is produced.