When I run the website locally, the video will upload to azure and I get a publish url. No problem. However, when I publish the website and then try to upload from there, I get this error:
Server Error in '/' Application.
--------------------------------------------------------------------------------
c:\V1.mp4
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileNotFoundException: c:\V1.mp4
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[FileNotFoundException: c:\V1.mp4]
Microsoft.WindowsAzure.MediaServices.Client.AssetFileData.UploadAsync(String path, BlobTransferClient blobTransferClient, ILocator locator, CancellationToken token) +499
Microsoft.WindowsAzure.MediaServices.Client.<>c__DisplayClass1c.<UploadAsync>b__14(Task`1 t) +347
System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke() +80
System.Threading.Tasks.Task.Execute() +49
[AggregateException: One or more errors occurred.]
System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) +3548265
System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) +10487717
System.Threading.Tasks.Task.Wait() +10
Microsoft.WindowsAzure.MediaServices.Client.AssetFileData.Upload(String path) +90
UploadTest.Upload.UploadVideoButton_Click(Object sender, EventArgs e) +101
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9553594
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +103
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724`enter code here`
Upload.aspx
<%# Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Upload.aspx.cs" Inherits="UploadTest.Upload" %>
<asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="server">
<asp:Button ID="UploadVideoButton" runat="server" Text="Upload The Video" OnClick="UploadVideoButton_Click" />
</asp:Content>
Upload.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.WindowsAzure.MediaServices.Client;
namespace UploadTest
{
public partial class Upload : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void UploadVideoButton_Click(object sender, EventArgs e)
{
CloudMediaContext context = new CloudMediaContext("<accountname>", "<accountkey>");
var asset = context.Assets.Create("V1.mp4", AssetCreationOptions.None);
var file = asset.AssetFiles.Create("V1.mp4");
file.Upload(#"c:\V1.mp4");
}
}
}
I think you should use this to upload file by uploading the stream
public void UploadFileToAzure(Stream stream, string fileName, string contentType,
EContextType contextType) {
if (stream == null)
throw new ArgumentNullException("stream");
if (fileName == null)
throw new ArgumentNullException("fileName");
CloudBlobContainer blobContainer = null;
switch (contextType)
{
case EContextType.CloudStorage:
blobContainer = AzureBlobUtil.InitializeBlob(Settings.AzureBlobStorageFileStorage, Settings.GetAzureDataConnectionString);
break;
default:
blobContainer = AzureBlobUtil.InitializeBlob(Settings.AzureBlobStorageDocument, Settings.GetAzureDataConnectionString);
break;
}
var blob = blobContainer.GetBlockBlobReference(fileName);
blob.UploadFromStream(stream);
blob.Metadata["FileName"] = fileName;
blob.Metadata["IsArchived"] = false.ToString();
blob.SetMetadata();
// Set the properties
blob.Properties.ContentType = contentType;
blob.SetProperties();
}
Related
I am using MailKit version 2.15.0. When trying to disconnect the client using DisconnectAsync, I am getting the below error
ClientDisconnect method()==> Exception Message: The ReadAsync method cannot be called when another read operation is pending., Exception String: System.NotSupportedException: The ReadAsync method cannot be called when another read operation is pending.
at System.Net.Security.SslStream.ReadAsyncInternal[TIOAdapter](TIOAdapter adapter, Memory`1 buffer)
at MailKit.Net.Pop3.Pop3Stream.ReadAheadAsync(Boolean doAsync, CancellationToken cancellationToken)
at MailKit.Net.Pop3.Pop3Stream.ReadLineAsync(Stream ostream, Boolean doAsync, CancellationToken cancellationToken)
at MailKit.Net.Pop3.Pop3Engine.ReadLineAsync(Boolean doAsync, CancellationToken cancellationToken)
at MailKit.Net.Pop3.Pop3Engine.ReadResponseAsync(Pop3Command pc, Boolean doAsync)
at MailKit.Net.Pop3.Pop3Engine.IterateAsync(Boolean doAsync)
at MailKit.Net.Pop3.Pop3Client.SendCommandAsync(Boolean doAsync, CancellationToken token, String command)
at MailKit.Net.Pop3.Pop3Client.DisconnectAsync(Boolean quit, Boolean doAsync, CancellationToken cancellationToken)
Below is the code I am using to Disconnect the Client
private async Task DisconnectClient(Hashtable markAsRead, EmailServer emailServer)
{
pollingInProgress = false;
await emailServer.ClientDisconnect(markAsRead);
markAsRead.Clear();
}
internal void MarkAsRead(Hashtable markAsRead)
{
emailBinding.emailSource().MarkRead(markAsRead);
}
internal async Task ClientDisconnect(Hashtable markAsRead)
{
try
{
if (!emailBinding.emailSource().IsConnected)
{
await emailBinding.Connect();
}
FlushClient(markAsRead);
await emailBinding.Disconnect();
}
catch (Exception e)
{
AttachWorkerLogs(string.Format("ClientDisconnect method()==> Exception Message: {0}, Exception String: {1}", e.Message, e.ToString()));
throw;
}
}
private void FlushClient(Hashtable markAsRead)
{
MarkAsRead(markAsRead);
}
Finally calling the disconnect method like this:
public async Task Disconnect()
{
try
{
if (client.IsConnected)
{
await client.DisconnectAsync(true);
}
}
catch (Exception e)
{
AttachLogger(string.Format("Disconnect method()==> Exception Message: {0}, Exception String: {1}", e.Message, e.ToString()));
throw;
}
}
I am unable to figure out what exactly is the issue.
The exception message makes it pretty clear that you are trying to read from the SslStream from multiple threads at the same time.
Since MailKit is not multi-threaded, it means that you are effectively trying to perform 2 or more operations on the same Pop3Client from multiple threads at the same time.
In other words, the problem is not that you are calling Disconnect, the problem is that you are calling Disconnect when your code is also trying to download messages or something from the server.
recently i have deployed my .net 5.0 api in azure web app without azure database. The app is running fine but i am not able to call any route which is getting data from my postgresql database. The api and getting data from my database is working fine in my local pc, but when i call any route in azure web app i get 500 internal server error and the detail error look like this.
error #1
Category: Microsoft.EntityFrameworkCore.Database.Connection
EventId: 20004
SpanId: 81307fd2722df04f
TraceId: 17283bbac7e9c74ab0dea8dafdf0a12a
ParentId: 0000000000000000
ConnectionId: 0HMB63E788EM6
RequestId: 0HMB63E788EM6:00000004
RequestPath: /api/someList
ActionId: d26cb19d-75cd-4847-828f-a74e2b5324ee
ActionName: QuranApi.Controllers.QuranTextController.GetSomeList (MyApi)
An error occurred using the connection to database 'MyDatabase' on server
'tcp://localhost:5432'.
error #2
Category: Microsoft.EntityFrameworkCore.Query
EventId: 10100
SpanId: 81307fd2722df04f
TraceId: 17283bbac7e9c74ab0dea8dafdf0a12a
ParentId: 0000000000000000
ConnectionId: 0HMB63E788EM6
RequestId: 0HMB63E788EM6:00000004
RequestPath: /api/someList
ActionId: d26cb19d-75cd-4847-828f-a74e2b5324ee
ActionName: QuranApi.Controllers.QuranTextController.GetSomeList (MyApi)
An exception occurred while iterating over the results of a query for context type
'QuranApi.PostgreSqlContext'.
System.InvalidOperationException: An exception has been raised that is likely due to
a transient failure.
---> Npgsql.NpgsqlException (0x80004005): Exception while connecting
---> System.Net.Sockets.SocketException (10013): An attempt was made to access a
socket in a way forbidden by its access permissions.
at Npgsql.NpgsqlConnector.Connect(NpgsqlTimeout timeout)
at Npgsql.NpgsqlConnector.Connect(NpgsqlTimeout timeout)
at Npgsql.NpgsqlConnector.RawOpen(NpgsqlTimeout timeout, Boolean async,
CancellationToken cancellationToken)
at Npgsql.NpgsqlConnector.Open(NpgsqlTimeout timeout, Boolean async,
CancellationToken cancellationToken)
at Npgsql.ConnectorPool.OpenNewConnector(NpgsqlConnection conn, NpgsqlTimeout
timeout, Boolean async, CancellationToken cancellationToken)
at Npgsql.ConnectorPool.<>c__DisplayClass38_0.<<Rent>g__RentAsync|0>d.MoveNext()
--- End of stack trace from previous location ---
at Npgsql.NpgsqlConnection.<>c__DisplayClass41_0.<<Open>g__OpenAsync|0>d.MoveNext()
--- End of stack trace from previous location ---
at Npgsql.NpgsqlConnection.Open()
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.
OpenDbConnection(Boolean errorsExpected)
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternal(Boolean
errorsExpected)
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open(Boolean
errorsExpected)
at
Microsoft.EntityFrameworkCore.Storage.RelationalCommand.
ExecuteReader(RelationalCommandParameterObject parameterObject)at
Microsoft.EntityFrameworkCore.Query.Internal.
SingleQueryingEnumerable`1.Enumerator.
InitializeReader(DbContext _, Boolean result)at
Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.
NpgsqlExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation,
Func`3 verifySucceeded)
--- End of inner exception stack trace ---
at
Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.
NpgsqlExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation,
Func`3 verifySucceeded)at Microsoft.EntityFrameworkCore.Query.Internal.
SingleQueryingEnumerable`1.Enumerator.MoveNext()
Exception:
System.InvalidOperationException: An exception has been raised that is likely due to
a transient failure.
---> Npgsql.NpgsqlException (0x80004005): Exception while connecting
---> System.Net.Sockets.SocketException (10013): An attempt was made to access a
socket in a way forbidden by its access permissions.
at Npgsql.NpgsqlConnector.Connect(NpgsqlTimeout timeout)
at Npgsql.NpgsqlConnector.Connect(NpgsqlTimeout timeout)
at Npgsql.NpgsqlConnector.RawOpen(NpgsqlTimeout timeout, Boolean async,
CancellationToken cancellationToken)
at Npgsql.NpgsqlConnector.Open(NpgsqlTimeout timeout, Boolean async,
CancellationToken cancellationToken)
at Npgsql.ConnectorPool.OpenNewConnector(NpgsqlConnection conn, NpgsqlTimeout
timeout, Boolean async, CancellationToken cancellationToken)
at Npgsql.ConnectorPool.<>c__DisplayClass38_0.<<Rent>g__RentAsync|0>d.MoveNext()
--- End of stack trace from previous location ---
at Npgsql.NpgsqlConnection.<>c__DisplayClass41_0.<<Open>g__OpenAsync|0>d.MoveNext()
--- End of stack trace from previous location ---
at Npgsql.NpgsqlConnection.Open()at
Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnection(Boolean
errorsExpected)
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternal(Boolean
errorsExpected)
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open(Boolean
errorsExpected) at
Microsoft.EntityFrameworkCore.Storage.RelationalCommand.
ExecuteReader(RelationalCommandParameterObject parameterObject)
at
Microsoft.EntityFrameworkCore.Query.Internal.
SingleQueryingEnumerable`1.Enumerator.InitializeReader(DbContext _, Boolean result)
at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlExecutionStrategy.
Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded)
--- End of inner exception stack trace ---
at
Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlExecutionStrategy.
Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded)
at
Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.
Enumerator.MoveNext()
error #3
Category: Microsoft.AspNetCore.Server.Kestrel
EventId: 13
SpanId: 81307fd2722df04f
TraceId: 17283bbac7e9c74ab0dea8dafdf0a12a
ParentId: 0000000000000000
ConnectionId: 0HMB63E788EM6
RequestId: 0HMB63E788EM6:00000004
RequestPath: /api/someList
Connection id "0HMB63E788EM6", Request id "0HMB63E788EM6:00000004": An unhandled
exception was thrown by the application.
Exception:
System.InvalidOperationException: An exception has been raised that is likely due to
a transient failure.
---> Npgsql.NpgsqlException (0x80004005): Exception while connecting
---> System.Net.Sockets.SocketException (10013): An attempt was made to access a
socket in a way forbidden by its access permissions.
my Program.cs File
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseUrls("https://localhost:5000", "https://IP-Address-of-my-PC")
.UseIISIntegration()
.UseStartup<Startup>();
});
}
And my Startup.cs File
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
var sqlConnectionString = Configuration["ConnectionString"];
services.AddDbContext<PostgreSqlContext>(options =>
options.UseNpgsql(connectionString: sqlConnectionString));
services.AddScoped<IDataAccessProvider, DataAccessProvider>();
services.AddSwaggerGen(options =>
{
options.SwaggerDoc("v1",
new OpenApiInfo
{
Title = "MyApi",
Version = "v1"
});
});
}
// This method gets called by the runtime.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
app.UseSwagger();
app.UseSwaggerUI(options =>
options.SwaggerEndpoint("/swagger/v1/swagger.json", "MyApi v1"));
}
}
i would be very happy if anybody can help me with this. I dont know what to do.
I'm trying to show custom error message for 404/403/500 error. I'm able to show 404/403 error but unable to show 500 error. Steps I have followed so far -
Step 1: Created a servlet which will set the status as 500
public class ErrorServlet extends SlingSafeMethodsServlet {
#Override
protected void doGet(final SlingHttpServletRequest request,
final SlingHttpServletResponse response) throws ServletException,
IOException {
try{
response.setStatus(500);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Step2: Crated Exception.jsp and Throwable.jsp under apps/sling/servlet/errorhandler
Step3: Added below code in both Exception.jsp and Throwable.jsp
<%#include file="/libs/foundation/global.jsp"%>
<%#taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling/1.0" %><%
%><sling:defineObjects /><%
response.setStatus(500);
request.getRequestDispatcher("/content/myproject/en_US/
errorpages/errorpage500.html").forward(request,response); %>
Now when I hit __http://port:host/path/to/servlet then I get "Internal Server Error" in the browser. It does not send to the expected custom error page which I mentioned.
Kindly let me know what I'm missing here.
I'm .net developer. now I'm working with crystal report. when I'm printing or exporting crystal report then print dialog open when I press Print, then no print operation occurs. This Print and Export not working at fire fox. only chrome support this functions. Is there extra code required for do this job.
---------------------------updated-----------------------------------------
at class declaration :
public partial class EndUser_FS_File_History : System.Web.UI.Page
{
ReportDocument reportdocument = null;
..........
at load crystal report:
reportdocument = new ReportDocument();
string connectionString = ConfigurationManager.ConnectionStrings["FileSystemConnectionString"].ConnectionString;
SqlConnectionStringBuilder SConn = new SqlConnectionStringBuilder(connectionString);
reportdocument.Load(Server.MapPath(#"~/Admin/UserReport.rpt"));
reportdocument.SetDataSource(myDataSet);
reportdocument.DataSourceConnections[0].SetConnection(SConn.DataSource, SConn.InitialCatalog, SConn.UserID, SConn.Password);
CrystalReportViewer1.ReportSource = reportdocument;
and at Page_Unload event:
protected void Page_Unload(object sender, EventArgs e)
{
if (reportdocument != null)
{
reportdocument.Close();
reportdocument.Dispose();
}
GC.Collect();
}
still problem occurs with large no of records:
The maximum report processing jobs limit configured by your system administrator has been reached.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: The maximum report processing jobs limit configured by your system administrator has been reached.
Source Error:
Line 782: string connectionString = ConfigurationManager.ConnectionStrings["FileSystemConnectionString"].ConnectionString;
Line 783: SqlConnectionStringBuilder SConn = new SqlConnectionStringBuilder(connectionString);
Line 784: reportdocument.Load(Server.MapPath(#"~/Admin/UserReport.rpt"));
Line 785: reportdocument.SetDataSource(myDataSet);
Line 786: reportdocument.DataSourceConnections[0].SetConnection(SConn.DataSource, SConn.InitialCatalog, SConn.UserID, SConn.Password);
Source File: f:\EasyWeb\Admin\User_Management.aspx.cs Line: 784
Stack Trace:
[COMException (0x80041016): The maximum report processing jobs limit configured by your system administrator has been reached.]
CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object& DocumentPath, Int32 Options) +0
CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object& DocumentPath, Int32 Options) +144
CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() +526
[CrystalReportsException: Load report failed.]
CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() +621
CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob) +1969
CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename) +186
Admin_User_Management.lbut_print_Click(Object sender, EventArgs e) in f:\EasyWeb\Admin\User_Management.aspx.cs:784
System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +111
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +79
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
There are few steps:
Before Pageload, declare the report as
ReportDocument rpt = null;
protected void Page_Load(object sender, EventArgs e)
{
try
{
rpt= new ReportName; //this is the name of your report
// do all the logic here
}
catch()
{
}
}
protected void Page_Unload(object sender, EventArgs e)
{
if(rpt!=null)
{
rpt.Close();
rpt.Dispose();
}
GC.Collect();
}
I'm new to JMS and I'm studying the following example
public class SendRecvClient
{
static CountDown done = new CountDown(1);
QueueConnection conn;
QueueSession session;
Queue que;
public static class ExListener
implements MessageListener
{
public void onMessage(Message msg)
{
done.release();
TextMessage tm = (TextMessage) msg;
try {
System.out.println("onMessage, recv text=" + tm.getText());
} catch(Throwable t) {
t.printStackTrace();
}
}
}
public void setupPTP()
throws JMSException,
NamingException
{
InitialContext iniCtx = new InitialContext();
Object tmp = iniCtx.lookup("ConnectionFactory");
QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
conn = qcf.createQueueConnection();
que = (Queue) iniCtx.lookup("queue/testQueue");
session = conn.createQueueSession(false,
QueueSession.AUTO_ACKNOWLEDGE);
conn.start();
}
public void sendRecvAsync(String text)
throws JMSException,
NamingException
{
System.out.println("Begin sendRecvAsync");
// Setup the PTP connection, session
setupPTP();
// Set the async listener
QueueReceiver recv = session.createReceiver(que);
recv.setMessageListener(new ExListener());
// Send a text msg
QueueSender send = session.createSender(que);
TextMessage tm = session.createTextMessage(text);
send.send(tm);
System.out.println("sendRecvAsync, sent text=" + tm.getText());
send.close();
System.out.println("End sendRecvAsync");
}
public void stop()
throws JMSException
{
conn.stop();
session.close();
conn.close();
}
public static void main(String args[])
throws Exception
{
SendRecvClient client = new SendRecvClient();
client.sendRecvAsync("A text msg");
client.done.acquire();
client.stop();
System.exit(0);
}
}
I ran this in JBoss and it gave the following exception
Begin sendRecvAsync
Exception in thread "main" javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at se.cambio.jms.SendRecvClient.setupPTP(SendRecvClient.java:53)
at se.cambio.jms.SendRecvClient.sendRecvAsync(SendRecvClient.java:68)
at se.cambio.jms.SendRecvClient.main(SendRecvClient.java:95)
I think this is an error with JNDI name, but I couldn't find which xml file to edit in JBOSS to over come this problem. Please some one help me.